Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django 2 error: Specifying a namespace in include() without providing an app_name #20

Open
lopezjurip opened this issue Mar 14, 2018 · 7 comments

Comments

@lopezjurip
Copy link

When using this library with Django 2 like:

from django.urls import include, path

urlpatterns = [
    # ...
    path('mfa/', include("deux.urls", namespace="mfa")),
]

Fails with:

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.

To make this work we need to add the variable app_name to

deux/urls.py
deux/oauth2/urls.py
deux/authtoken/urls.py

@gonzaloamadio
Copy link

with which value?

@VirtualKley
Copy link

Use app_name='nameapp'
in urls for applications, after urlpatterns

@rozacek
Copy link

rozacek commented Feb 18, 2020

Can you provide a code example? Because as I'm typing app_name="sth" in urls.py it doesn't work.

@GabrielDumbrava
Copy link

Can you provide a code example? Because as I'm typing app_name="sth" in urls.py it doesn't work.

Let's say in your main urls.py you want to include the urls of an app, called shop_app, like this:
path("shop/", include("shop_app.urls", namespace='shop')),

Then, in your urls.py file of your shop_app located in shop_app/urls.py, after the urlpatters add the app_name like this:

urlpatterns = [
   ... some patterns
]

app_name = 'shop'

If you don't have access to the shop_app urls, as in case you are using an included package, then you'll have to drop the namespace from your main include and remove the namespace references from your url tags, or from your reverse functions.

@DonExo
Copy link

DonExo commented Mar 21, 2020

Or you can also use it this way:

path('mfa/', include(("deux.urls", 'app_name'), namespace="mfa")),

@amontecino
Copy link

Excelent ¡¡¡

@Gathiira
Copy link

as indicated by @DonExo

path('', include(('blog.urls', 'blog'), namespace='blog'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants