id,summary,reporter,owner,description,type,status,component,version,severity,resolution,keywords,cc,stage,has_patch,needs_docs,needs_tests,needs_better_patch,easy,ui_ux
8663,Inconsistencies/Bug in ModelForm,lingrlongr,nobody,"When a ModelForm is used to display a form for a Model, the fields defined with a choices option insert a ""-------"" value for the first option when the form is rendered. If you override a field and manually specify the choices for a Select widget, this ""-------"" does not appear as the first choice.
{{{
# models.py
from django.db import models
MY_CHOICES = (
(0, 'Zero'),
(1, 'One'),
)
class MyModel(models.Model):
my_field = models.IntegerField(choices=MY_CHOICES)
}}}
{{{
# forms.py
from django import forms
from myapp.models import MyModel, MY_CHOICES
class MyModelForm(forms.ModelForm):
#my_field = forms.IntegerField(widget=forms.Select(choices=MY_CHOICES))
class Meta:
model = MyModel
}}}
View the HTML for the form with my_field commented out:
{{{
>>> from myapp.forms import MyModelForm
>>> f = MyModelForm()
>>> print f