Home > Software design >  template rendering works fine but when I use template inheritance it displays error
template rendering works fine but when I use template inheritance it displays error

Time:05-23

I tried the using {% include 'navbar.html'%} on room.html template both of them work fine and display the template but when I add {% include 'navbar.html'%} in room.html try to render it displays this error I adjust have also include the templates in the setting what seems to be the problem. The urls file in first app is

from django.urls import path
from . import views
urlpatterns =[
path('',views.home),
path('room/',views.room),
path('navbar/',views.navbar),
            

and the views file is like this

from django.shortcuts import render
from django.http import HttpResponse
def home(request):
 return render(request,'firstapp/home.html')
def room(request):
 return render(request,'firstapp/room.html')
def navbar(request):
 return render(request,'firstapp/navbar.html')    
def main(request):
 return render(request,'main.html') 

   images of error displayed in Django and setting file

[1]: https://i.stack.imgur.com/MH8fL.png error displayed in Django

[2]: https://i.stack.imgur.com/Wh8Ot.png error displayed in Django [3]: https://i.stack.imgur.com/phUt0.png settings file

CodePudding user response:

Welcome at SO! Don't post code/errors in pictures. Help community help you :)

You probably need to use:

{% include 'firstapp/navbar.html' %}
  • Related