19π
Well everything is fine, the trouble that you are having is that
you are confused, just naming a block in base does not calls it.
Mark the difference between extends and include.
You have counfused extends to include.
Once in your views if you call say index.html it will be rendered properly.
The effect you want can be achieved by changing the base.html in your views to index.html.
Hope this helps. more can be read here: https://docs.djangoproject.com/en/dev/topics/templates/#template-inheritance
3π
For more people who end up here (as myself), main thing to note is that when you use {% extends 'something.html' %}
, you cannot use anything other than these template tags at the top-level.
You can obviously have html tags inside these tags (like block tags), but donβt put ANYTHING outside the template tags.
- Django Whitenoise 500 server error in non debug mode
- How to debug Django custom management command using VS Code
- In django, is there a way to directly annotate a query with a related object in single query?
- Execute code on model creation in Django
0π
Also helps if you change the path in extends, for example {% extends 'mysite/index.html' %}
. And view function must render the file with extends, not the basic one.
0π
In views.py, you have to call the template that extends the other template, not the other way around. In your example you should call nav.html.
- Uploading images using Django Admin?
- The default "delete selected" admin action in Django
- How to embed matplotlib graph in Django webpage?
- Django queryset return single value
- How do I construct a Django form with model objects in a Select widget?