views:

41

answers:

1

I have a model that has a foreign key relation to another. I'd like to have the dropdown that is produced by widget=forms.Select have a default value

+1  A: 

Maybe just create form and set field's intial value?

class SomeForm(forms.ModelForm):

    class Meta:
        model = SomeModel
        fields = ('field')

    def __init__(self, *args, **kwargs):
        super(SomeForm, self).__init__(*args, **kwargs)
        self.fields['field'].initial = 'inital_value'
yedpodtrzitko