include() app的urls.py,然后在app/urls.py下省略应用名 直接view.index,然后出错了,为什么?
我和官方文档的例子应该是一样的,为什么会出错啊
以下是我的结构
这是报错信息
ImportError at /test/
No module named views
project下的urls可以正常使用from app import views
应用下的urls死活不成功
google找到了变相的办法
You prefixed your route names with a relative module name. Use an absolute name:
urlpatterns = patterns('',
url(r'^$', "moments_app.views.index", name='index'),
url(r'^$', "moments_app.views.choose_dataset", name='choose'),
url(r'^get_moments/', "moments_app.views.get_moments", name='get_moments'),
url(r'^learn/$', "moments_app.views.learn", name='learn'),
url(r'^(?P<moment_id>\d+)/$', "moments_app.views.detail", name='detail'),
)
or better still, use the first argument to specify the full module path:
urlpatterns = patterns('moments_app.views',
url(r'^$', "index", name='index'),
url(r'^$', "choose_dataset", name='choose'),
url(r'^get_moments/', "get_moments", name='get_moments'),
url(r'^ [...]
3
julyclyde 2015-03-18 21:22:45 +08:00
所以啊,建议大家读一下常用框架的初始化部分、创建urlschema的部分,会对动态加载和字符串处理有新的认识
|