#9640: BooleanField with choices, defaults, and blank=False still given blank
option in their formfields
-------------------------------+--------------------------------------------
          Reporter:  Nate      |         Owner:  fperetti                       
    
            Status:  new       |     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):

 Hi, I've been working with fperetti and could reproduce part of the issue.
 AFAIK the issue should be splitted in two parts:


 1. When the blank = True is passed to the models.BooleanField, the
 generated HTML (using ModelForm) is not consistent with that, as it adds
 the "------" option.
 2. When the default = N is passed to the models.BooleanField, the
 generated HTML does not have the default = "default"


 We could '''only''' reproduce the first one using this:

 {{{
 #models.py

 from django.db import models

 # Create your models here.

 CHOICE = [(1,'si'),(2,'no')]
 class Ejemplo(models.Model):
        buleanito = models.BooleanField(choices=CHOICE,default=1,
 blank=False)

 }}}

 {{{
 # forms.py
 from django.forms import ModelForm
 from coso.models import Ejemplo

 class MiFormulario(ModelForm):
     class Meta:
         model = Ejemplo

 }}}


 {{{
 ./ḿanage shell

 from coso.forms import MiFormulario
 a = MiFormulario()
 print(a)

 <tr><th><label for="id_buleanito">Buleanito:</label></th><td><select
 name="buleanito" id="id_buleanito">

 <option value="">---------</option>   # <-------------------------- THIS
 IS WRONG!!!

 <option value="1" selected="selected">si</option>

 <option value="2">no</option>

 </select></td></tr>

 }}}

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