[Django]-Django create instance of model from another models save method

5👍

You could instead use post_save signal for creating catalog objects at the time of creation of article objects. This would ensure creation of the catalog objects, without having to include non-relevant code in the article models’ save method.

from django.db.models.signals import post_save

# method for updating
def create_catalog(sender, instance, created, **kwargs):
     if instance and created: 
         #create article object, and associate


post_save.connect(create_catalog, sender=Article)

Leave a comment