1👍
The method="…"
of the form is "POST"
, not the :action="…"
<form method="post"> {% csrf_token %} <p>Are you sure you want to delete {{organism.genus}} {{organism.species}} {{organism.strain}}?</p> <p>This cannot be undone!</p> <input type="submit" class="btn btn-danger" value="confirm"/> </form>
It might be better to work with reverse_lazy(…)
[Django-doc] to determine the path of the success_url
:
from django.urls import reverse_lazy
class OrganismDeleteView(LoginRequiredMixin, DeleteView):
model = Organism
success_url = reverse_lazy('organism_list')
template_name = 'library/organism_delete.html'
login_url = '/login'
0👍
When you do <form action="post" ...
, you are asking the form to "append post
to the current URL, using a GET request, and go the endpoint with ‘your data’".
More details here: https://www.w3schools.com/tags/att_form_action.asp
I am not sure how will you manage to make the page call again the same page (maybe omit action="..."
, but you should add (change) method="..."
; from the implicit method="get"
, make it a method="post"
instead.
Without being a django connoisseur myself, it would be nice if you could "easily" teach django to listen to the method="delete"
instead of POST
, as it will make your API a tad more semantic.
- [Answered ]-AxiosInstance raise error ->( Invalid token specified) -> after update -> user profile information ? why ? please solve it
- [Answered ]-Is it possible to use both cheaper and emperor with uWSGI
- [Answered ]-Is there a short way to do Django objects.create()