Here is notification that I got, and activities
target is always None. How can we assign target instance in Model?
{'id': '6a4e1d107c07b2c7',
...,
'activities': [
EnrichedActivity(activity_data={'id': '6a4e1d18-e3b8-11e7-8080-80007c07b2c7', 'to': ['notification:1'], 'time': datetime.datetime(2017, 12, 18, 5, 58, 5, 508124), 'foreign_id': 'comment.Comment:22', 'object': <Follow: johnmatt3 : jbaek7023>, 'actor': <User: johnmatt3>,
'target': None, <-- ALWAYS None. Why?
'verb': 'follow', 'origin': None}, not_enriched_data={}),
EnrichedActivity(activity_data={'id': '62b0e89c-e3b8-11e7-8080-80017680d313', 'to': ['notification:1'], 'time': datetime.datetime(2017, 12, 18, 5, 57, 52, 733814), 'foreign_id': 'follow.Follow:21', 'object': <Follow: jbaek7023433 : jbaek7023>, 'actor': <User: jbaek7023433>, 'target': None, 'verb': 'follow', 'origin': None}, not_enriched_data={})],
'is_seen': True, 'verb': 'comment'},
Here is Comment class. I guess there would be a certain property to set the 'target'
class Comment(models.Model, Activity):
user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='follower')
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField()
target = GenericForeignKey('content_type', 'object_id')
@property
def activity_notify(self):
SomeModel = self.content_type.model_class()
...
return []
I need the specific property which can handle which instance should the target
. such as...
@property
def activity_target_attr(self): # this is not working
print('test')
target = blah blah
return target
# expected output...
# {id... activities: [EnrichedActivity(
# 'id': ..., 'target': <Outfit 32> ...),...}