if you create your
index.html file on
templates/index.html,then you can use this settings on your
TEMPLATES = [
# Add 'TEMPLATE_DIR' here
then in your view you need to render that file:
return render(request, 'index.html', context=context)
You have to use a TemplateView. It is just a simple view that serve a template html.
from django.views.generic import TemplateView
template_name = "PATH_TO_INDEXHTML"
Just add an url in urls.py for serving this view and let’s go
from django.urls import path
from .views import IndexView
urlpatterns = [
More information about templateview: https://docs.djangoproject.com/fr/4.1/ref/class-based-views/base/#django.views.generic.base.TemplateView
My index is loading well on browser, but when I click home page, there is nothing 404 error, is responding static/index.html, (when I click home page or any other such as contact, it is searching for html in static) why is it asking for index.html in static files and how can I rectify that?[
I stored my html files on templates folder thinking that when i clicked my dropdown, they were going to apper on my web.
Am not very sure what you asked, but I have everything required such as html, static files and everything and my pages are present exactly like shown in the image above, unless am missing something am not aware of!