felix001
felix001

Reputation: 16691

Initial Form Values

I have a form like the following,

class CacheCheck(forms.Form):
    type = forms.TypedChoiceField(choices=TYPE_CHOICES, initial='FIXED')
    record = forms.TypedChoiceField(choices=RECORD_CHOICES, initial='FIXED')
    hostname = forms.CharField(max_length=100)

However how do you remove the label from the input and also set the inital value to the drop down. However the inital value should not be one of the choices.

Thanks,

Upvotes: 0

Views: 102

Answers (1)

guettli
guettli

Reputation: 27796

You can remove the label like this.

class CacheCheck(forms.Form):
    def __init__(self, *args, **kwargs):
        forms.Form.__init__(self, *args, **kwargs)
        self.fields['type'].label=''

I know that this does not solve everything in your question, but it should help you get you started.

Upvotes: 1

Related Questions