set field attributes in inherited classes in a DRY fashion in Django -


My code is below, I'm actually redefining my vehicle_make so that the legacy Could change its initial value in the millisecond (update format). I'm looking for a dry outlook I was trying to field ['filename']. Initial = "value", but it gives mainstream. BaseInputForm (forms.ModelForm): class meta: model = vehicle exclusion = ('vehicle_make', 'vehicle_model') def __init __ (self, * args, ** kwargs): super (SearchInforms, itself) .__ init __ (* Args, ** kwargs) self.fields ['vehicle_make'] = forms.ChoiceField (initial = "NA", label = "car build", option =, widget = Select forms (etters = {'id': 'creates'}) class CreateForm (BaseInputForm): Close class UpdateForm (BaseInputForm): def __init __ (self, * args, ** kwargs): super (SearchUpdateForm, self ) .__ init __ (* args, ** kwargs) self.vehicle_make = self.instance.vehicle_make self.fields ['vehicle_make'] = forms.ChoiceField (start Select (= '' id ':' creates'}) # self field ['vehicle_make']. Initial = "auto =" .hhicle_make, label = "make car", option =, create widget = forms. self.instance.vehicle_model

Try:

  self.fields ['fieldname']. initial = "value"   

has its own keyword that you are missing

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -