Skip to content

Instantly share code, notes, and snippets.

@nwjlyons
Last active March 29, 2018 17:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nwjlyons/c02aee9f0f408a3815b3b741cafe4eee to your computer and use it in GitHub Desktop.
Save nwjlyons/c02aee9f0f408a3815b3b741cafe4eee to your computer and use it in GitHub Desktop.
Django 2.0 nested URLs
# https://docs.djangoproject.com/en/2.0/topics/http/urls/#including-other-urlconfs
from django.urls import include, path
from . import views
# Change this
urlpatterns = [
path('<page_slug>-<page_id>/history/', views.history),
path('<page_slug>-<page_id>/edit/', views.edit),
path('<page_slug>-<page_id>/discuss/', views.discuss),
path('<page_slug>-<page_id>/permissions/', views.permissions),
]
# To this
urlpatterns = [
path('<page_slug>-<page_id>/', include([
path('history/', views.history),
path('edit/', views.edit),
path('discuss/', views.discuss),
path('permissions/', views.permissions),
])),
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment