我在我的主url文件中使用djangos include特性,来自我的app url文件。你知道吗
主要网址.py你知道吗
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^posts/', include('posts.urls')),
]
你知道吗帖子.url.py你知道吗
from django.conf.urls import url
from . import views #relative import to post views
urlpatterns = [
url(r'$',"views.posts_list" ), #list all posts
url(r'create/$',"views.posts_create" ),
url(r'detail/$',"views.posts_detail" ),
url(r'update/$',"views.posts_update" ),
url(r'delete/$',"views.posts_delete" ),
]
错误如下:
raise TypeError('view must be a callable or a list/tuple in the case of include().')
TypeError: view must be a callable or a list/tuple in the case of include().
我看过关于这个问题的文件: https://docs.djangoproject.com/en/1.11/ref/urls/#include
以及源代码:
https://docs.djangoproject.com/en/1.11/_modules/django/conf/urls/#include
我不知道我做错了什么。你知道吗
请帮忙。拥抱亲吻,击掌
django1.10+不再允许您在URL模式中将视图指定为字符串(例如
'myapp.views.index'
)。你知道吗所以你应该这样配置你的帖子
urls.py
:向url中添加
name
也是一种很好的做法。你知道吗相关问题 更多 >
编程相关推荐