#3457: Allow overriding of error message for each newforms Field type
-------------------------+--------------------------------------------------
   Reporter:  anonymous  |                Owner:  nobody         
     Status:  new        |            Component:  django.newforms
    Version:  SVN        |           Resolution:                 
   Keywords:             |                Stage:  Accepted       
  Has_patch:  1          |           Needs_docs:  1              
Needs_tests:  1          |   Needs_better_patch:  0              
-------------------------+--------------------------------------------------
Comment (by SmileyChris):

 For a quick summary of how it works:
 
  1. each `Field` instance gets an `error_messages` dictionary built from
 the `default_error_messages` in it's class (and base classes, recursively)
 
  2. a user can pass in their own `error_messages` dictionary which
 `.update()`s the `error_messages` dictionary for that instance
 
 {{{
 >>> from django.newforms import *
 >>> d = DecimalField(error_messages={'invalid':'Mr T says, "Enter a valid
 number, foo!"'})
 >>> d.clean('jibberjabber')
 
 Traceback (most recent call last):
   File "<pyshell#72>", line 1, in -toplevel-
     d.clean('jibberjabber')
   File "[...]\django\newforms\fields.py", line 237, in clean
     raise ValidationError(self.error_messages['invalid'])
 ValidationError: [u'Mr T says, "Enter a valid number, foo!"']
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/3457#comment:11>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to