您好,当我尝试从Django 2.0旧项目中运行服务器时遇到问题。

这是错误:

      File "/usr/lib/python3.7/site-packages/django/urls/conf.py", line 39, in include
    '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.'


这是我的urls.py

from django.conf.urls import url, include
from django.contrib import admin
from apps.sysgrub.views import LoginUser, LogoutUser

app_name = 'apps'

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^alumno/', include ('apps.alumno.urls', namespace="alumno")),
    url(r'^grupo/', include ('apps.grupo.urls', namespace="grupo")),
    url(r'^maestro/', include ('apps.maestro.urls', namespace="maestro")),
    url(r'^rol/', include ('apps.rol.urls', namespace="rol")),
    url(r'^sysgrub/', include ('apps.sysgrub.urls', namespace="sysgrub")),
    url(r'^$', LoginUser),
    url(r'^logout/$', LogoutUser),
]


和我的网址按应用

urlpatterns = [
url(r'^index$', index),
url(r'^horarios$', horarios),
url(r'^listar$', Alumno_grupoList.as_view(), name='alumno_listar'),
url(r'^agregar$', AlumnoCreate.as_view(), name='add_student'),

]


非常感谢您的帮助。

最佳答案

错误描述了解决方法,请从urls.py中删除应用名称,如下所示

urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^alumno/', include ('alumno.urls', namespace="alumno")),
url(r'^grupo/', include ('grupo.urls', namespace="grupo")),
]

关于python - 我无法运行服务器Django 2.0,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53093045/

10-12 16:59