python - Django post_save not getting many-to-many attributes on create -
i binding post_save
method model in django, following code:
def save_mymodel(sender,instance,*args,**kwargs): print 'save called' parameter in instance.parameters.all(): print parameter.name post_save.connect(save_mymodel, sender=mymodel)
here models:
def mymodel(models.model): parameters = models.manytomanyfield(parameter) def parameter(models.model): name = models.charfield(max_length=100)
when try create mymodel
django admin number of parameters, save called
output. if save same mymodel
object again admin, parameters printed. difference between calling save
on create , not on create? how can make sure attributes of model using post_save
on creation?
manytomany
fields not participate in model save()
method, post_save
not recognize m2m changes. detect m2m change, use m2m_changed
signal.
Comments
Post a Comment