一尘不染

AttributeError:“模块”对象没有属性“ URL”

python

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


阅读 235

收藏
2021-01-20

共1个答案

一尘不染

在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文档中了解更多信息

2021-01-20