﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
28691	Breaking change for 2.0: app_name no longer in include, but in urls.py	Christian Kreuzberger	nobody	"I believe I found a way to improve the documentation for the upcoming 2.0 release. I found out about this as I had an old 1.8 app that I am trying to get compatible with 1.11 and 2.0.

The ""breaking changes"" documentation in the 2.0 release notes states that

* The {{{app_name}}} argument to {{{include()}}} is removed.

However, it does not state that you now should (or even have to) specify the {{{ app_name }}} attribute in your urls.py.

With Django 1.8 to 1.11 the following did work:

myproject/urls.py:
{{{
from django.conf.urls import url, include
from myproject.views import reset_password_request_token, reset_password_confirm

urlpatterns = [
    url(r'^confirm', reset_password_confirm, name=""reset-password-confirm""),
    url(r'^', reset_password_request_token, name=""reset-password-request""),
]
}}}

Somewhere else in the main urls.py:
{{{
urlpatterns = [
    url(r'^api/password_reset/', include('myproject.urls', namespace='myproject')),
]
}}}

With 2.0 you will get the following error:

{{{
 File ""~/myproject/venv/lib/python3.5/site-packages/django/urls/conf.py"", line 39, in include
    'Specifying a namespace in include() without providing an app_name '
django.core.exceptions.ImproperlyConfigured: Specifying a namespace in include() without providing an app_name is not supported. Set the app_name attribute in the included module, or pass a 2-tuple containing the list of patterns and app_name instead.
}}}


The obvious fix is to specify {{{app_name}}} in myproject/urls.py like this:
{{{
from django.conf.urls import url, include
from myproject.views import reset_password_request_token, reset_password_confirm

app_name=""myproject""

urlpatterns = [
    url(r'^confirm', reset_password_confirm, name=""reset-password-confirm""),
    url(r'^', reset_password_request_token, name=""reset-password-request""),
]
}}}

I believe it might be worth adding this information to the list of breaking changes, stating that you have to specify the {{{app_name}}} attribute in your urls.py now. Might also be worth linking to the documentation for configuring urls.py properly, as {{{app_name}}} has been in there since 1.9:
https://docs.djangoproject.com/en/2.0/topics/http/urls/#url-namespaces-and-included-urlconfs

"	Cleanup/optimization	closed	Documentation	2.0	Normal	worksforme	breaking change, documentation, app_name		Unreviewed	0	0	0	0	0	0
