小编Kin*_*ing的帖子

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

Python 2.7 和 Django 1.10 错误:

AttributeError: 'module' object has no attribute 'urls' 
Run Code Online (Sandbox Code Playgroud)

主/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))

]
Run Code Online (Sandbox Code Playgroud)

文章/urls.py

from django.conf.urls import url
from . import views

urlpatterns = [

    url(r'^$', views.basic_one, name='basic_one')
]
Run Code Online (Sandbox Code Playgroud)

结构:

应用程序/main/urls.py

应用程序/文章/urls.py

python django python-2.7 web

5
推荐指数
1
解决办法
2万
查看次数

TemplateDoesNotExist 但它存在

Python 2.7 & Django 1.10 我的模板存在,但我做错了!

TemplateDoesNotExist at /basicview/2/
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>TEST</title>
</head>
<body>
This is template_two view!
</body>
</html>

Request Method:     GET
Request URL:    http://127.0.0.1:8000/basicview/2/
Django Version:     1.10.1
Exception Type:     TemplateDoesNotExist
Exception Value:    

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>TEST</title>
</head>
<body>
This is template_two view!
</body>
</html>

Exception Location:     /home/i/djangoenv/local/lib/python2.7/site-packages/Django-1.10.1-py2.7.egg/django/template/loader.py in get_template, line 25
Python Executable:  /home/i/djangoenv/bin/python
Python Version:     2.7.11
Python Path:    

['/home/i/djangoenv/bin/firstapp',
 '/home/i/djangoenv/lib/python2.7',
 '/home/i/djangoenv/lib/python2.7/plat-i386-linux-gnu',
 '/home/i/djangoenv/lib/python2.7/lib-tk',
 '/home/i/djangoenv/lib/python2.7/lib-old',
 '/home/i/djangoenv/lib/python2.7/lib-dynload',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-i386-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/home/i/djangoenv/local/lib/python2.7/site-packages',
 '/home/i/djangoenv/local/lib/python2.7/site-packages/Django-1.10.1-py2.7.egg',
 '/home/i/djangoenv/lib/python2.7/site-packages', …
Run Code Online (Sandbox Code Playgroud)

python django django-templates python-2.7

1
推荐指数
1
解决办法
6370
查看次数

标签 统计

django ×2

python ×2

python-2.7 ×2

django-templates ×1

web ×1