Python 2.7和Django 1.10错误:
AttributeError: 'module' object has no attribute 'urls'
main / urls.py
from django.conf.urls import url, include from django.contrib import admin import article urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^', include(article.urls)) ]
article / urls.py
from django.conf.urls import url from . import views urlpatterns = [ url(r'^$', views.basic_one, name='basic_one') ]
结构体:
APP / main / urls.py
APP /文章/urls.py
在main / urls.py中
from django.conf.urls import url, include from django.contrib import admin from article import urls urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^', include(urls)) ]
要么
from django.conf.urls import url, include from django.contrib import admin urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^', include('article.urls')) ]
您可以从Django文档中了解更多信息