9👍
The easiest way to do this is:
Insert the following code in your base.html
#base.html
{% block title %} {% endblock %}
and following in your index or any Html file with your title
#index.html
{% extends 'base.html'%}
{% block title %} My Page Title {% endblock %}
0👍
Place your context object key in double paranthesis.
Lets take am making a dynamic teacher’s page in a school management system
#urls.py
path("teacher/<str:pk>/",views.teacher,name="teacher"),
The vew
#view
def teacher(request,pk):
teacher = Teacher.objects.get(id=pk)
context= {"teacher":teacher}
return render(request,'main/teacher.html',context)
The template
<title>{{teacher.fname}} Page</title>
- [Django]-Filter on ManyToManyField intermediate table fields
- [Django]-Is there a reason I should be dissuaded from using an alternative templating engine in my Django app?
- [Django]-Django .."join" query?
Source:stackexchange.com