Why does index.html have such a name in Django?

60 Views Asked by At

I’m not a native speaker and I don’t understand why the standard name of the initial page in Django applications is index.html. Can someone explain in simple words why this is so, and not, for example, home.html

I'm trying to find out the answer to my question. I just need a verbal explanation

2

There are 2 best solutions below

0
On BEST ANSWER

I'm not a native speaker and I don’t understand why the standard name of the initial page in Django applications is index.html.

It isn't, Django recommends not to name pages with an extension. The basic path used is:

#    🖟🖟 empty
path('', views.index, name='index')

so for the "outside world", we use the empty path, and you can name the view whatever you like.

The tradition to name such file index.html originates from the fact that in the very old days, web servers were often seen as "file repositories". So a lot of webservers stored a file named foo.txt, and you accessed it with domain.com/foo.txt. Now if one visited the domain.com/ itself, one expects a "list" of the files available, so an index, since a book contains often also a list of the content named the "index" section.

0
On

Because that's what that file has been called long before Django even existed.