使用url的时候添加app_name,提示错误:Specifying a namespace in include() without providing an app_name ' django.core.exceptions.ImproperlyConfigured: Specifying a ...

在使用url的时候,有些地方是这样写的:

 url(r'^blog/', include('blog.urls', namespace='blog',app_name='blog'))

  但是会报错:

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

只需要换种写法即可:

 url(r'^blog/', include(('blog.urls', 'blog'), namespace='blog'))

  

原文地址:https://www.cnblogs.com/mmykdbc/p/13594104.html