save() in post save keep calling itself(recursive)
to solve this try:
Just use pre_save , you don't need to use .save() method inside it again.
class Status(models.Model):
body = models.TextField(max_length=200)
image = models.ImageField(blank=True, null=True, upload_to=get_upload_file_name)
privacy = models.CharField(max_length=1,choices=PRIVACY, default='F')
pub_date = models.DateTimeField(auto_now_add=True, auto_now=False)
user = models.ForeignKey(User)
class Activity(models.Model):
actor = models.ForeignKey(User)
action = models.CharField(max_length=100)
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
pub_date = models.DateTimeField(auto_now_add=True, auto_now=False)
default_app_config = 'activity.apps.ActivityAppConfig'
from django.apps import AppConfig
class ActivityAppConfig(AppConfig):
name = 'activity'
def ready(self):
import activity.signals
post_save.connect(create_activity_item, sender=Status,
dispatch_uid="create_activity_item")
if ctype.name == 'status':
class MyModel(models.Model):
""" MyModel fields go """
body = models.TextField(max_length=200)
pub_date = models.DateTimeField(auto_now_add=True, auto_now=False)
def post_save_actions(sender, instance, created, **kwargs):
if created:
pass
# post save actions if new instance is created,
# do something with `instance` or another models
# be careful about circular imports. m/