在使用Django2.0,配置全局URL时,希望指向某个APP的URL,配置如下:
但却出现了问题,重启服务时,报以下错误:
而使用Django1.0,则会可以正常运行。
原因是:在Django1.0中include的源码是:
def include(arg, namespace=None, app_name=None):
if app_name and not namespace:
raise ValueError('Must specify a namespace if specifying app_name.')
if app_name:
warnings.warn(
'The app_name argument to django.conf.urls.include() is deprecated. '
'Set the app_name in the included URLconf instead.',
RemovedInDjango20Warning, stacklevel=2
)
是可以接收app_name参数的,而在Django2.0中:
def include(arg, namespace=