Named URLs and reverse
Give each route a name and use reverse() or the url template tag instead of hard coding paths. Links keep working when you change the URL.
Example
from django.urls import reverse
reverse("detail", args=[5]) # "/blog/post/5/"
# In a template
# <a href="{% url 'detail' post.id %}">Read</a>Exercise
Build a URL from a name.
("detail", args=[5])Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.