class Follow(models.Model): """ Lets a user follow the activities of any specific actor """ user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, db_index=True) content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE, db_index=True) object_id = models.CharField(max_length=255, db_index=True) follow_object = GenericForeignKey() actor_only = models.BooleanField( "Only follow actions where " "the object is the target.", default=True) flag = models.CharField(max_length=255, blank=True, db_index=True, default='') started = models.DateTimeField(default=now, db_index=True) objects = FollowManager() class Meta: unique_together = ('user', 'content_type', 'object_id', 'flag') def __str__(self): return '%s -> %s : %s' % (self.user, self.follow_object, self.flag)
class Follow(models.Model): """ Lets a user follow the activities of any specific actor """ user = models.ForeignKey(user_model_label) content_type = models.ForeignKey(ContentType) object_id = models.CharField(max_length=255) follow_object = generic.GenericForeignKey() actor_only = models.BooleanField("Only follow actions where " "the object is the target.", default=True) started = models.DateTimeField(default=now) objects = FollowManager() class Meta: unique_together = ('user', 'content_type', 'object_id') def __str__(self): return '%s -> %s' % (self.user, self.follow_object)