django中url无法include怎么配置?,djangoinclude,我有一个project
django中url无法include怎么配置?,djangoinclude,我有一个project
我有一个project 跟目录的root url conf 设置内容为:
----------------------------------------------------------
from django.conf.urls import patterns, include, urlimport funnytesturlpatterns = patterns(url(r'^funnytest/', include('funnytest.urls')),url(r'^helloworld/', funnytest.views.hello),)
-----------------------------------------------------------
其中funnytest是其中一个app,funnytest 目录下设置了一个Urls, 内容为:
------------------
from django.conf.urls import patterns, include, urlfrom views import *urlpatterns = patterns(url(r'^hello/$', hello),)
-------------------
我访问 localhost/funnytest/hello/ 会报错,表示urls 中没有匹配的配置
但是访问localhost/helloworld 是可以访问到view hello 的
为什么呢,应该如何配置~
应该这样写"url(r'^funnytest/', include('funnytest.urls',namespace="funnytest")),"
from django.conf.urls import patterns, include, urlfrom views import *urlpatterns = patterns(url(r'^hello/$', hello),)
第二个url写法是有问题的,导入模块写法应该是from app.views import hello这个格式,在django中,都应该这种导入方法。
另入,像第二个,我平时是这么写的:
url(r'^hello/$', 'app.viwes.hello`),
多看下django book里面的url写法。
http://stackoverflow.com/questions/12...
编橙之家文章,
相关内容
- Python3前景好不好,python3前景,最终由3统一,还是一直分
- 关于微信订阅号支付接口的问题请教,给个思路,订阅
- Python控制登录时间有效性的方法要如何写?,python有效性
- 树莓派单核CPU运行多个Tornado程序性能方面的问题,树莓
- Python private函数使用疑惑,pythonprivate,>>> class M
- Python文件头部编码声明两种不同写法有区另吗?,pytho
- 不是很明白python代码输出的结果,求讲解,python代码,这
- Python语言适合做PC端软件开发吗,pythonpc,Java 和Python
- Python jinja2列表如何使用append方法添加元素?,jinja2ap
- Python print出现提示__main__.Observer object at 0x0224F3B0是何原
评论关闭