[Fixed]-Django-need to create model object when related forigenkey model object is created

1👍

You can use Signals:

from django.db.models.signals import post_save
#if a new object of product_detail is created then a new status should be created automatically
@receiver(post_save, sender=production_detail)
def create_status(sender, instance, created, *args, **kwargs):
    if created:
          obj = status(machineinfo=instance)
          obj.save()
👤trantu

Leave a comment