Django Wht Post Signal Signal Not tir
default_app_config = 'activity.apps.ActivityAppConfig'
Relieved Ratel
default_app_config = 'activity.apps.ActivityAppConfig'
post_save.connect(create_activity_item, sender=Status,
dispatch_uid="create_activity_item")
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/
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)
from django.apps import AppConfig
class ActivityAppConfig(AppConfig):
name = 'activity'
def ready(self):
import activity.signals
if ctype.name == 'status':