On 17/04/2008, eXt <[EMAIL PROTECTED]> wrote: [...] > 'object_category' is represented by django.newforms.ModelChoiceField > and is rendered as a 'Select'. The field has 'required = True'. The > problem is that the 'Select' always contains a blank value: '<option > value="">---------</option>'. > > ModelForm docs say: "The blank choice will not be included if the > model field has blank=False and an explicit default value (the default > value will be initially selected instead)." Blank is True and default > doesn't make sense here... but even setting it to a value existing in > a related model doesn't help me to get rid of blank value. > > Is there any way to do that, other than manually generating choices: > In AnObjectForm's __init__: > > self.fields['object_category'].widget = > forms.RadioSelect(choices=[(c.id, c) for c in > self.fields['object_category'].queryset])
There is an empty_label kwarg you can set to None to supress the "-----" option so I guess something like: self.fields['object_category'].empty_label = None should do what you want (assuming you are using svn trunk). -- Phil Davis --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---