Template tag “follow_all_url” failed to render unfollow links in django-activity-stream
I have been trying django-activity-stream for weeks now and it is a great Django app. Everything worked great until today, when the tag “follow_all_url” stops rendering unfollow urls.
I tracked back the problem back to a function in class DisplayActivityFollowUrl in activity_tags.py file:
[python toolbar=”true”]
def render(self, context):
actor_instance = self.actor.resolve(context)
content_type = ContentType.objects.get_for_model(actor_instance).pk
if Follow.objects.is_following(context.get(‘user’), actor_instance):
return reverse(‘actstream_unfollow’, kwargs={
‘content_type_id’: content_type, ‘object_id’: actor_instance.pk})
if self.actor_only:
return reverse(‘actstream_follow’, kwargs={
‘content_type_id’: content_type, ‘object_id’: actor_instance.pk})
return reverse(‘actstream_follow_all’, kwargs={
‘content_type_id’: content_type, ‘object_id’: actor_instance.pk})
[/python]
context.get(‘user’) is supposed to get the request.user, but instead it gets nothing. A similar question on stackflow indicates that a setting might be missing, which is not the case but I think it is something wrong with how I created the view. I use class-based generic view and here is how my get_context_data() looks like:
[python]
def get_context_data(self, **kwargs):
ctx = kwargs
ctx[‘users’] = User.objects.all()
return super(StreamView, self).get_context_data(**ctx)
[/python]
Doesn’t look like it is the problem:(
I remember at first I used activity-stream with pinax-project-account project, and it worked with pinax-user-account app which also does something with the context_processing setting. In this new project I remove the user-account app and switched it with django-social-auth, maybe it missed something in my context?
I haven’t found a solution yet, but I will post the update to the problem here. For now, I think I can temporarily change that line to context.get(‘request’).user instead.
Update:
It was quite stupid actually, I have an object list in the template called “users”, so in a for loop each iterated item is called “user”. Change that to “people” solved the problem.