#12595: Localflavor bad arguments handling
----------------------------------------+-----------------------------------
 Reporter:  sayane                      |       Owner:  nobody    
   Status:  new                         |   Milestone:  1.2       
Component:  django.contrib.localflavor  |     Version:  SVN       
 Keywords:                              |       Stage:  Unreviewed
Has_patch:  1                           |  
----------------------------------------+-----------------------------------
 A lot of form fields in django.contrib.localflavor handles arguments to
 {{{__init__()}}} in a bad way.

 {{{
     def __init__(self, *args, **kwargs):
         super(PLPESELField, self).__init__(r'^\d{11}$',
             max_length=None, min_length=None, *args, **kwargs)
 }}}

 Every line like first one should be fixed like this:

 {{{
     def __init__(self, max_length=None, min_length=None, *args, **kwargs):
 }}}

 Because if someone will pass {{{max_length}}} or {{{min_length}}} argument
 to {{{__init__()}}} it will fail (multiple
 {{{min_length}}}/{{{max_length}}} arguments - additional one will be in
 {{{kwargs}}}).

 It is a big problem, if i'm trying to do something like this:

 {{{
 class PostalCodeField(models.CharField):
     def formfield(self, **kwargs):
         kwargs.setdefault("form_class", PLPostalCodeField)
         return super(self.__class__, self).formfield(**kwargs)
 }}}
 because {{{django.db.models.CharField}}} sets {{{max_length}}} to
 {{{self.max_length}}}.

 I'm attaching patch to fix polish localflavor.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12595>
Django <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 django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.


Reply via email to