0
By default DeleteView
does deletion only on POST
request. So your user will not be able to delete items just making GET
request.
But for your information all class based views(CBV) call dispatch
method which then calls ether post
or get
depending on request.method
.
You can add some logic directly in dispatch
method or modify get
and do your checks there
Example
class MyDeleteView(DeleteView):
def post(self, request, *args, **kwargs):
...
def get(self, request, *args, **kwargs):
# here you can make redirect to any url
...
1
It should be a POST, there isnβt any need to check it yourself.
From the docs
The given object will only be deleted if the request method is POST. If this view is fetched via GET, it will display a confirmation page that should contain a form that POSTs to the same URL.
- Javascript ajax request not running with Selenium tests
- Django + AJAX query model without refreshing the page
- Angular JS convert 2 dim JSON in django
Source:stackexchange.com