Django Form BidForm(request.POST or None) sometime load form data otherwsie null

Solution for Django Form BidForm(request.POST or None) sometime load form data otherwsie null
is Given Below:

I have following BidForm Class…

class BidForm(ModelForm):
    # listing = forms.CharField(widget=forms.HiddenInput())


    class Meta:
        model = Bids
        fields = ('listing', 'bid_price')


    # def clean_bid_price(self):
    #     data = self.cleaned_data["bid_price"]
    #     listing = self.instance.listing
    #     if listing.last_high_bid:
    #         if data <= listing.last_high_bid.bid_price:
    #             raise forms.ValidationError('bid price less than last bid price')
    #     else:
    #         if data < listing.starting_bid_price:
    #             raise forms.ValidationError('bid price less than starting price')
    #     return data
  1. The moment I uncomment either listing field or clean_bid_price validation method, the form can not load the form data and I get form instance with instance object set to None type.

  2. If I leave the form as it is, then I debugged full init method for form and could not see where post data is loaded. To the best I could see in pycharm debugger the post data is never loaded on form or model instance in init method. However somehow magically the model instance of form get post data and field set. Already spent quite a lot of time trying to debug simple function but not sure why it’s failing.

  3. When is clean methods on fields called? In django 3.1.7 that I have clean method is not getting called at all as _errors is having empty dict and is_valid or self._errors is not able to hit self.clean method at all.