开发者

Django sample DeleteView [duplicate]

This question already has answers here: Closed 10 years ago.

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.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 开发者_如何学JAVA What am doing wrong?


As the error says, you need to pass some sort of parameter to the view so it knows which item to delete... for example:

url(r'^del/(?P<slug>\w+)/$', DeleteFormView.as_view()),


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜