python - self.instance in Django ModelForm -


what self.instance in django modelform constructor mean , can find documentation it?

class mymodelform(modelform):     def __init__(self, *args, **kwargs):         super(mymodelform, self).__init__(*args, **kwargs)         if self.instance:         ... 

in modelform, self.instance derived model attribute specified in meta class. self in context instance of subclass of modelform, , self.instance (and on saving form without errors) instance of model class specified, although have not done in example.

accessing self.instance in __init__ may not work, though doing after calling parent's __init__ will. further, wouldn't recommend trying change instance directly. if interested, have @ basemodelform code on github. instance can specified when creating new form via instance argument.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -