From 8cbca4229f6a030a977d4928811d1cf590e765f4 Mon Sep 17 00:00:00 2001 From: Adam Kelly Date: Mon, 24 Feb 2020 15:10:03 +0000 Subject: [PATCH] Add following as a related_name for followers. --- fedireads/incoming.py | 2 +- .../migrations/0008_auto_20200224_1504.py | 19 +++++++++++++++++++ fedireads/models/user.py | 3 ++- 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 fedireads/migrations/0008_auto_20200224_1504.py diff --git a/fedireads/incoming.py b/fedireads/incoming.py index 225177ce..bb1d0771 100644 --- a/fedireads/incoming.py +++ b/fedireads/incoming.py @@ -187,7 +187,7 @@ def get_following(request, username): return HttpResponseBadRequest() user = models.User.objects.get(localname=username) - following = models.User.objects.filter(followers=user) + following = user.following page = request.GET.get('page') return JsonResponse(activitypub.get_following(user, page, following)) diff --git a/fedireads/migrations/0008_auto_20200224_1504.py b/fedireads/migrations/0008_auto_20200224_1504.py new file mode 100644 index 00000000..1ddbc8cd --- /dev/null +++ b/fedireads/migrations/0008_auto_20200224_1504.py @@ -0,0 +1,19 @@ +# Generated by Django 3.0.3 on 2020-02-24 15:04 + +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('fedireads', '0007_auto_20200223_0902'), + ] + + operations = [ + migrations.AlterField( + model_name='user', + name='followers', + field=models.ManyToManyField(related_name='following', through='fedireads.UserRelationship', to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/fedireads/models/user.py b/fedireads/models/user.py index 37c9cbca..f3289003 100644 --- a/fedireads/models/user.py +++ b/fedireads/models/user.py @@ -38,7 +38,8 @@ class User(AbstractUser): 'self', symmetrical=False, through='UserRelationship', - through_fields=('user_subject', 'user_object') + through_fields=('user_subject', 'user_object'), + related_name='following' ) favorites = models.ManyToManyField( 'Status',