WebFaction
Community site: login faq

forms.py

def clean(self):
        cleaned_data = self.cleaned_data
        if 'phone_daytime' in cleaned_data:
            validate_integer(cleaned_data['phone_daytime'])
            raise ValidationError('Phone number must be number')
            return cleaned_data

        if 'phone_mobile' in cleaned_data:
            validate_integer(cleaned_data['phone_mobile'])        
            return cleaned_data

template.py

    <tr>
       <td>Daytime phone:</td><td>{{ form.phone_daytime }}{{ form.phone_daytime.errors }}</td>
    </tr>
    <tr>
      <td>Mobile phone:</td><td>{{ form.phone_mobile }}{{ form.phone_mobile.errors }}</td>
    </tr>

Validation happening,error message is not throwing in template.(raise ValidationError('Phone number must be number')) is not executed .

Thanks

asked 15 May '13, 02:12

pychu
3158
accept rate: 0%

edited 16 May '13, 11:27

seanf
12.2k42136

How have you determined that the validation is actually happening?

Since you are explicitly raising the validation error in your if block, I'd say the conditions for that if block (if 'phone_daytime' in cleaned_data) aren't being met.

(16 May '13, 11:41) seanf
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×910
×30
×20
×8

question asked: 15 May '13, 02:12

question was seen: 2,516 times

last updated: 16 May '13, 11:41

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM