August 21, 2022
In case when you need to initialize form with already predefined details of the form instance, for example form that add comment to a post - you can predefine post_id in the form instance instead applying it in the save() method.
...
August 21, 2022
Easy way to redirect user on previous (original) page after form processing it is use HTTP_REFERER header, here an example how it’s may be implemented in the get_success_url() of the Django’s class based view.
...
August 21, 2022
In case if you need to make some validation steps directly in the view’s def form_valid() method and raise an ValidationError here an example
...
August 17, 2022
Working with complex views that process multiple forms you can stuck on situation when some of forms didn’t valitated but you have not see a reason for this, to debug this you can print forms errors from the view POST method.
...
August 17, 2022
Sometimes you need to represent boolean field of the Django model as dropdown list choices, like “Yes/No” instead default boolean field form widget - CheckboxInput. You can implement it like this.
...