Include Other URLconfs
A snippet showing how to include URLs from other apps.
# models.py
from django.db import models
class Section(models.Model):
name = models.CharField(max_length=50)
# admin.py
from django.contrib import admin
from .models import Section
@admin.register(Section)
class SectionAdmin(admin.ModelAdmin):
list_display = ("name",)
# project/urls.py
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path("admin/", admin.site.urls),
path("blog/", include("blog.urls")),
]
# blog/urls.py
from django.urls import path
from . import views
urlpatterns = [
path("", views.index, name="blog-index"),
]
Explanation:
-
Use
include()to delegate to an app's URLconf and keep project URLs tidy. - App URLconfs can be swapped or versioned independently.
- Category URLs & Routing
- Total Views 331
- Last Modified 23 March, 2026
- Tags #urls #include #apps #routing
Previous snippet
Using re_path() for Regex URLs
Next snippet