Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » Question about custom form widgets and validation [RSS Feed]

#1 Dec. 30, 2010 00:00:47

Brandon T.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Question about custom form widgets and validation


Hi everyone,

I'm working on a custom form widget to input length values in feet,
inches and a fraction of an inch. So far, everything is working as
expected, except for validation.

It takes a value input as:
1' 10 1/2" and converts it into inches: 22.5, for storage in a
database.

My widget combines two text inputs and a select to create the decimal
value. So, I'm using a DecimalField and supplying my widget. However,
if I input a non-numeric value, I'm getting a ValueError in my
value_from_datadict method.

So, obviously I need a try/except in that method, but how do I go
about adding an error message to the field instead of raising a
runtime exception?

Once I get this finished, I'd like to add it to Django Snippets to
share.

Thanks,
Brandon

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » Question about custom form widgets and validation [RSS Feed]

Board footer

Moderator control

Enjoy the 17th of August
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support