'Specifying a namespace in include() without providing an app_name '

'Specifying a namespace in include() without providing an app_name ’

从include()函数能够看出来,这个函数有两个参数,一个arg,一个namespace,我在代码中也是两个参数,可是异常中提示了,没有提供app_name,还提示须要传入一个两元元组,从第六行代码urlconf_module, app_name = arg能够看出来,arg就是那个元组,且给app_name赋值了,因此咱们这里修改代码为:django

 #课程机构URL配置
    #url(r'^org/', include('organization.urls',namespace="org")),
    url(r'^org/', include(('organization.urls',"org"),namespace="org")),
    #课程相关URL配置
    #url(r'^coursess/', include('coursess.urls',namespace="coursess")),
    url(r'^coursess/', include(('coursess.urls','coursess'),namespace="coursess")),
    #用户信息相关url配置
    url(r'^users/', include(('users.urls','users'),namespace="users")),

  解释:注释的为django1.9版本的,django2.1用非注释部分就能够了解决了app

下面和上面非注释部分是django2.1版本里正确的写法:函数

url(r'^org/', include(('organization.urls',"org"),namespace="org")),
相关文章
相关标签/搜索