0

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 What am doing wrong?

Community
  • 1
  • 1
altman
  • 21
  • 1
  • 4

2 Answers2

6

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()),
Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
0

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

Community
  • 1
  • 1
saul.shanabrook
  • 3,068
  • 3
  • 31
  • 49