How do you update a Django Form Meta class fields dynamically from the form constructor? -
 I want to dynamically update  Meta.fields . Is it possible to do this form constructor? I tried the following but the  year  form is not visible during the generation. Only  names  and  titles  are displayed. 
  Category author (models.Model): name = ... title = ... year = ... class partial official form: model meta: model = author area = ('name ',' Title ') def __init __ (self, * args, ** kwargs): self.meta.fields + = (' year ',)   
 No, this will not work, the meta is parsed - surprisingly - metaclass, even before you go to  __ init __  . 
 The way to do this manually  self.fields : 
  def __init __ (self, * args, ** kwargs): super (Partial author, self) .__ init __ (* args, ** kwargs) self.fields ['year'] = Forms.CharField (whatever)   
Comments
Post a Comment