Django 示例删除视图
几小时后的搜索我只是不知道如何使用删除视图。对不起我的愚蠢? 有人能给我举个例子吗?
url( r'^del/$', DeleteFormView.as_view( ) ),
class DeleteFormView( BaseDeleteView ):
model = user_info
context_object_name = "user_info_list"
DeleteFormView 必须使用对象 pk 或 slug 调用
这个错误一直存在 我做错了什么?
Possible Duplicate:
Example of Django Class-Based DeleteView
after hours search i just didn't know how to use DeleteView. Sorry for my foolish?
Can some one give me a example?
url( r'^del/
DeleteFormView must be called with either an object pk or a slug
this error always exist
What am doing wrong?
, DeleteFormView.as_view( ) ),
class DeleteFormView( BaseDeleteView ):
model = user_info
context_object_name = "user_info_list"
DeleteFormView must be called with either an object pk or a slug
this error always exist
What am doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如错误所述,您需要将某种参数传递给视图,以便它知道要删除哪个项目......例如:
As the error says, you need to pass some sort of parameter to the view so it knows which item to delete... for example:
另一篇文章可能会回答您的一些问题。你走在正确的轨道上,就像 @Daniel 所说,URL 中需要有某种标识符传递给视图,告诉它要删除什么。
如需使用模板的完整示例,查看 Django 用户表格
Another post might answer some of your questions. You are on the right track, and like @Daniel said, there needs to be some sort of identifier in the URL to pass to the view to tell it what to delete.
For a full example with a template, look to the Django-users form