#9640: BooleanField with choices, defaults, and blank=False still given blank
option in their formfields
-------------------------------+--------------------------------------------
          Reporter:  Nate      |         Owner:  fperetti                       
    
            Status:  reopened  |     Milestone:  1.1                            
    
         Component:  Forms     |       Version:  1.0                            
    
        Resolution:            |      Keywords:  BooleanField, FormField, 
choice set
             Stage:  Accepted  |     Has_patch:  0                              
    
        Needs_docs:  0         |   Needs_tests:  0                              
    
Needs_better_patch:  0         |  
-------------------------------+--------------------------------------------
Comment (by nmiyasato):

 So we found that the BooleanField class forces us to have the blank value
 to True

 {{{
 #!python
  Index: django/db/models/fields/_init_.py
 ===================================================================
 --- django/db/models/fields/_init_.py (revisión: 10119)
 +++ django/db/models/fields/_init_.py (copia de trabajo)
 @@ -371,7 +371,7 @@

 class BooleanField(Field):
     def __init__(self, *args, **kwargs):
 -        kwargs['blank'] = True  # <------------- This is always set to
 True!!!
 +        kwargs['blank'] = False
         if 'default' not in kwargs and not kwargs.get('null'):
             kwargs['default'] = False
         Field.__init__(self, *args, **kwargs)
 }}}

 As kwargs[blank] is set always to True, it doesn't matter what we pass to
 the BooleanField.

 Does anybody know why this is set always to True?

 I can't have a select/combobox with only two options, neither of them
 being the "--------" one, as it always adds it.

 A patch has been submitted, but please tell us why this is hardcoded to
 the True value.
 With this patch, sub-issue *1*

 Thanks a lot

-- 
Ticket URL: <http://code.djangoproject.com/ticket/9640#comment:10>
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-updates@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