Breaking

Code Gripper
Responsive Advertisement
  • Home
Home

Django DeleteView without confirmation template

byMahabubur Rahman -January 11, 2022
0

DeleteView responds to POST and GET requests, GET request display confirmation template, while POST deletes instance.


You can send POST request, without confirmation with form like this:


<form method="POST" action="{% url "your_delete_url_name" %}">

   {% csrf_token %}<input type="submit" value="DELETE">

</form>

If you do not want to have a link instead form button, use some javascript to make invisible form, that will be submitted on link click.


It is not good practice to use GET request for updating or deleting, but if you really insist you can shortcut get method in your class view to post, ie:


def get(self, *args, **kwargs):

    return self.post(*args, **kwargs)

  • Facebook
  • Twitter

You may like these posts

Post a Comment

Previous Post Next Post

Follow Us

Popular Posts

CKEditor5

ModuleNotFoundError: No module named 'ckeditor_uploader'

byMahabubur Rahman-September 13, 2022

ModuleNotFoundError: No module named 'rest_framework'

August 17, 2022

Subscribe Us

Facebook

Categories

Main Tags

Code Gripper

September 30, 2023

Total Pageviews

Search This Blog

CODE GRIPPER

Code Gripper
CODE GRIPPER

  • Home
  • Python
  • PHP

Menu Footer Widget

  • Home
  • About
  • Contact Us
Code Gripper

About Us

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's.

Categories

Main Tags

Latest Posts

Most Popular

ModuleNotFoundError: No module named 'ckeditor_uploader'

September 13, 2022

ModuleNotFoundError: No module named 'rest_framework'

August 17, 2022
Design by Blogger | Distributed by Gooyaabi
  • Home
  • About Us
  • Contact Us
  • RTL Version

Contact Form