django-bootstrap-modal-forms
django-bootstrap-modal-forms copied to clipboard
BSModalDeleteView generates warning in Django 4
Object will be deleted, but the redirection to the views success_url doesn't work. Instead you get a warning
python3.10/site-packages/django/views/generic/base.py:62: DeleteViewCustomDeleteWarning:
DeleteView uses FormMixin to handle POST requests. As a consequence, any custom deletion logic in
BlogPostDeleteView.delete() handler should be moved to form_valid().
self = cls(**initkwargs)
Simply downgrading django to 3.2.11 makes it work again.
$(".delete-book").each(function () { $(this).modalForm({formURL: $(this).data("form-url"), isDeleteForm: true}); });
Passing in isDeleteForm: true solves the problem.
Oh, stupid me, you are completely right. Had a look in previous projects and recognised, i had done so. Thanks
Sorry, I have to reopen this, although it maybe a minor issue. Deleting works fine, but the warning still appears:
DeleteViewCustomDeleteWarning: DeleteView uses FormMixin to handle POST requests. As a consequence, any custom deletion logic in ImageDeleteView.delete() handler should be moved to form_valid().
self = cls(**initkwargs)
There's no "delete" logic in my view class.
I try to have a closer look into it.
Seems to be intended behaviour: https://docs.djangoproject.com/en/4.0/releases/4.0/#generic-views and that means that in the DeleteMessageMixin the content of the delete method should be moved to the form_valid method.
I will try if this is backwards compatible with django 3 in the next days.
Simply moving the content of delete to form_valid is running with django3.2 and 4.0 but breaks the tests for 3.2 und lower. Any hint to keep this compatible?
Found that simply moving the logic in DeleteMessageMixin from delete to post is fully compatible with django 3.2 and django 4 and doesn't break any tests. Will send a pull request...
@trco, is it possible to accept this pull request and release a new version? Thanks!
Still brings the warning
@Justinspryce Can you please describe what exactly you've tested? I just reviewed the pull request with Django 4.1 and got no warning.
Closed with #216.