ModelAdmin
class InstrumentAdmin(admin.ModelAdmin):
def get_form(self,request, obj=None, **kwargs):
if obj:
return UpdateForm
else:
return CreateForm
Update Form
class UpdateForm(forms.ModelForm):
connector = forms.ModelChoiceField(queryset=Connector.objects.all(), widget=forms.Select(attrs={'disabled':'disabled'}), initial='multiplate')
class Meta:
model = Instrument
fields = ['connector','name']
I have set initial value for the ChoiceField. But when i access the change of the model and Save, it prompt me "This field is required" for the field connector.
How can I make the field not mandatory in this case? Because it will always have a value there.