1👍
You should not add test/index.html
at the end of your url in the browser, just something like http://127.0.0.1:8000/ and make sure that templates/test/index.html
exists.
0👍
Django’s url routing uses regular expressions to match routes.
url(r'^$', index, name='index'),
In this case you have just a single valid route, which is the empty string r'^$'
. So you can only get a response by visiting for example http://localhost:8000
. All other urls will fail.
Django’s url routing is completely independent from where your template files are located on your file system. Therefore http://localhost/test/index.html
will not be valid, even though there is a template file with that name.
You could make a catch-all route by using this pattern that will match any url path.
url(r'', index, name='index'),
- Pre loading templates and template variables before parsing in Django
- Django REST framework: deserializing an existing foreign key fails
- Django query return primary key related column values
- Django – Model with lists in a CharField
Source:stackexchange.com