Skip to content

Tag: django

Django: Get previous value in clean() method

I have a model CustomModel with an IntegerField. When I create a new instance of CustomModel in the admin, I have to do validation, so I use the clean method and have access to the value with. My problem: When I change the instance of CustomModel, I only have access to the new, changed value but not to the or…

Pass argument to Django form

There are several questions on stackoverflow related to this topic but none of them explains whats happening neither provides working solution. I need to pass user’s first name as an argument to Django ModelForm when rendering template with this form. I have some basic form: Here’s my sample class…