Django Custom Field cleaning for Integer


I have this puzzling django form

Here is part of my handling the POST request

def getUpdataBet(request, name):


    elif request.method == 'POST':

         Bound_form = form_Net(request.POST, instance=obj)

         if Bound_form.is_valid():

                new_tag =

                return render(request, 'Account\Sucess.html', .........)


                 render(request, ......)


And my has this custom cleaning for the form page.


def clean_BetAccountBalance(self):

       Data = self.cleaned_data.get(BetAccountBalance)

       If Data > 800:

             raise forms.ValidationError("Value too Large")


               return data


My question is that, In my form page when i give a value greater than 800, it returns the validation error as usual. But when i input a value lesser than 800, the form page acts as bound_form.is_valid() is false

The most puzzling thing is that when i comment out the if and else statement, it works perfectly fine and returns the cleaned_data perfectly. Is it that you dont use an if statement in a custom clean method.? May 25, 2017, 2:51 p.m. 0 Answer

Warning! You are not logged in.
Your answer will be published as Guest user.

Post your Answer

 Prev question