Is there any reason this doesn't work? / Any way to make it work? (without defining another choice set)
class Foo(models.Model):
BAR_CHOICES = ((str(x), str(x)) for x in range(5))
bar = models.CharField(max_length = 1, choices = BAR_CHOICES)
barbar = models.CharField(max_length = 1, choices = BAR_CHOICES)
class FooForm(forms.ModelForm):
class Meta:
model = Foo
class FooAdmin(admin.ModelAdmin):
pass
admin.site.register(Foo, FooAdmin)
Then if you go to the admin
page or make a ModelForm
, the choices only show up for the first field
Like so:
>> foo_form = FooForm()
>> print foo_form
<tr><th><label for="id_bar">Bar:</label></th><td><select name="bar" id="id_bar">
<option value="" selected="selected">---------</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select></td></tr>
<tr><th><label for="id_barbar">Barbar:</label></th><td><select name="barbar" id="id_barbar">
<option value="" selected="selected">---------</option>
</select></td></tr>
edited to show FooForm, FooAdmin, and Admin img