ImproperlyConfiguredError about app_name when using namespace in include()

前端 未结 5 1833
北荒
北荒 2020-12-02 14:59

I am currently trying out Django. I use the namespace argument in one of my include()s in urls.py. When I run the server and try to browse, I get t

5条回答
  •  無奈伤痛
    2020-12-02 15:46

    I included a library not (fully) django 2.1 compatible yet (django_auth_pro_saml2). Hence I create a second file saml_urls.py:

    from django_saml2_pro_auth.urls import urlpatterns
    
    app_name = 'saml'
    

    Such that I could include the urls as:

    from django.urls import include, re_path as url
    
    urlpatterns = [
        ..., url(r'', include('your_app.saml_urls', namespace='saml')), ...
    ]
    

    Hacky, but it worked for me, whereas the url(r'^reviews/', include(('reviews.urls', 'reviews'), namespace='reviews')) did not.

提交回复
热议问题