Small fix, episode two

This commit is contained in:
Skia 2016-12-08 15:30:41 +01:00
parent 9847186b06
commit c1397ef5a5

View File

@ -23,7 +23,7 @@ def search_user(query, as_json=False):
users = User.objects.filter(Q(first_name__icontains=query) | users = User.objects.filter(Q(first_name__icontains=query) |
Q(last_name__icontains=query)).exclude(id__in=exact_nick).exclude(id__in=nicks).all() Q(last_name__icontains=query)).exclude(id__in=exact_nick).exclude(id__in=nicks).all()
nicks = nicks[:5] nicks = nicks[:5]
users = users[:5] users = users[:50]
if as_json: # Re-loads json to avoid double encoding by JsonResponse, but still benefit from serializers if as_json: # Re-loads json to avoid double encoding by JsonResponse, but still benefit from serializers
exact_nick = json.loads(serializers.serialize('json', exact_nick, fields=('nick_name', 'last_name', 'first_name', 'profile_pict'))) exact_nick = json.loads(serializers.serialize('json', exact_nick, fields=('nick_name', 'last_name', 'first_name', 'profile_pict')))
nicks = json.loads(serializers.serialize('json', nicks, fields=('nick_name', 'last_name', 'first_name', 'profile_pict'))) nicks = json.loads(serializers.serialize('json', nicks, fields=('nick_name', 'last_name', 'first_name', 'profile_pict')))