Created
July 16, 2019 21:46
-
-
Save aballah-chamakh/1350985fa6272a5306ab2f912b69a4c3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.db.models.signals import post_save | |
| from django.dispatch import receiver | |
| @receiver(post_save, sender=Article) | |
| def set_analytic_to_article(sender, instance, created, **kwargs): | |
| if created : | |
| analytic_obj = Analytic.objects.create(views=0) | |
| instance.analytic = analytic_obj | |
| instance.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment