Opened 7 years ago

Closed 7 years ago

#29361 closed Cleanup/optimization (wontfix)

django.contrib.flatpages.urls does not have an app_name attribute

Reported by: William Morrell Owned by: nobody
Component: contrib.flatpages Version: 2.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In 2.0, the include function in django.urls changed to drop the app_name argument, but an app_name attribute to the urls module is still required when setting a namespace on an include call. The urls.py in contrib.flatpages does not include an app_name attribute, so code like this will break:

urlpatterns = [
    # ...
    path('my-flat-pages/', include('django.contrib.flatpages.urls', namespace='my-custom-namespace')),
]

Change History (1)

comment:1 by Carlton Gibson, 7 years ago

Resolution: wontfix
Status: newclosed

You're right: there is no app_name but we can't just introduce one, since that would break existing usages.

If you want to namespace the URLs you can use the third case from the `include()` docs:

include((pattern_list, app_namespace), namespace=None)

Assuming you don't also need a instance namespace, you'd do something like:

from django.contrib.flatpages.urls import urlpatterns as flatpages_patterns

urlpatterns = [
    # ...
    path('my-flat-pages/', include((flatpages_patterns, 'my-custom-namespace',)),
]
Note: See TracTickets for help on using tickets.
Back to Top