Generic CBV DeleteView GET csrf_token

21 views
Skip to first unread message

B

unread,
Mar 14, 2019, 3:05:22 PM3/14/19
to Django users
I'm implementing a DeleteView, and for completion I would like to provide the functionality indicated here:


If this view is fetched via GET, it will display a confirmation page that should contain a form that POSTs to the same URL.

However, by default a GET will not include the required context to the template for {% csrf_token %}. How do I include the appropriate context information for a plain DeleteView CBV?

Chetan Ganji

unread,
Mar 14, 2019, 3:24:46 PM3/14/19
to django...@googlegroups.com

I’m protected online with Avast Free Antivirus. Get it here — it’s free forever.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/213ca896-0973-4b64-9345-50de5cd9e5d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

B

unread,
Mar 14, 2019, 3:32:50 PM3/14/19
to Django users
Thanks. I have things working fine under Ajax. This particular scenario is an "odd one" since performing a GET on a delete view isn't common, but it is implemented by Django. It is helpful for testing, but perhaps the right approach is to "disable" get for the DeleteView and be done with it. My main concern was for Django to behave "out of box" as intended without overrides.

Chetan Ganji

unread,
Mar 14, 2019, 3:38:12 PM3/14/19
to django...@googlegroups.com
Frameworks dont work as we want them too :P 
We have to understand how the defaults are implemented then make the changes as necessary ;-) 
If it can be customized, great! otherwise learn and use a different framework, LOLZ ;-) 


Regards,
Chetan Ganji
+91-900-483-4183


I’m protected online with Avast Free Antivirus. Get it here — it’s free forever.

Reply all
Reply to author
Forward
0 new messages