通用编辑 URL 在 Django 中不起作用

发布于 2024-11-17 17:09:24 字数 750 浏览 4 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

皓月长歌 2024-11-24 17:09:24

您错过了 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)

桜花祭 2024-11-24 17:09:24

正确的反斜杠需要。这也咬我了。我想这会伤害很多新手。这是修复的高优先级。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文