通用编辑 URL 在 Django 中不起作用
我正在使用 Django 通用视图,但是当我输入
/book/edit/9/
然后它说配置文件中没有 URL macthed
我的 URL 文件是
from django.conf.urls.defaults import *
from django.conf.urls.defaults import *
from myapp.views import *
from django.contrib import admin
from django.conf import settings
from django.views.generic.simple import direct_to_template
from django.views.generic import list_detail
from myapp.models import *
from django.views.generic import create_update
from django.views.generic.create_update import update_object
book_info = {'model' : Book}
(r'^book/create/$', create_update.create_object, book_info),
(r'^book/edit/(?P<object_id>d+)/$',create_update.update_object,book_info),
创建部分工作正常
I am using Django generic View but when i type
/book/edit/9/
Then it says no URL macthed in config file
My URL file is
from django.conf.urls.defaults import *
from django.conf.urls.defaults import *
from myapp.views import *
from django.contrib import admin
from django.conf import settings
from django.views.generic.simple import direct_to_template
from django.views.generic import list_detail
from myapp.models import *
from django.views.generic import create_update
from django.views.generic.create_update import update_object
book_info = {'model' : Book}
(r'^book/create/
The create part is working fine
, create_update.create_object, book_info),
(r'^book/edit/(?P<object_id>d+)/
The create part is working fine
,create_update.update_object,book_info),
The create part is working fine
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您错过了 d (
\d
) 上的转义符:您想要(r'^book/edit/(?P\d+)/$',create_update.update_object ,book_info)
You're missing the escape on the d (
\d
): you want(r'^book/edit/(?P<object_id>\d+)/$',create_update.update_object,book_info)
正确的反斜杠需要。这也咬我了。我想这会伤害很多新手。这是修复的高优先级。
Correct on the backslash need. This bit me too. I suspect this is hurting a lot of newbies. This is a high priority for fixing.