About Lesson
What are URL Namespaces?
URL namespaces allow you to organize your URLs, particularly in larger projects, to avoid naming conflicts and make it easier to reverse URLs in templates and views.
Example:
In your urls.py
:
In your template or view, you can use the namespace to reverse the URL:
- app_name: The namespace for the app’s URLs.
{% url 'books:book-list' %}
: This references thebook-list
URL in thebooks
app namespace.
Join the conversation