1👍
✅
Below code examples show the answer to my question.
Model form class
class NewBidForm(forms.ModelForm):
class Meta:
model = Bid
fields = '__all__'
def __init__(self, *args, **kwargs):
my_arg = kwargs.pop('my_arg')
super(NewBidForm, self).__init__(*args, **kwargs)
self.fields['bid'].validators=[MinValueValidator(my_arg)]
Then every time a form object is instantiated make sure to pass in the my_variable
like so:
form = NewBidForm(my_arg=my_variable)
My mistake was to instantiate the form at two locations in my code but only passing the argument in one of the instances.
I
- [Answered ]-FIlter instances that has the same field as instance id of which I provide in one query?
Source:stackexchange.com