Django 1.8: Unable to use queries in a query

I am trying to do this:

wider_circle = # some queryset
friends_you_may_know = list(wider_circle.exclude(user_id__in=user.connections))

But I get this error:

RemovedInDjango19Warning: Passing callable arguments to queryset is deprecated

It worked on Django 1.6, but threw an error on 1.8

Thank:)

+4
source share
1 answer

I guess that connectionsis a lot for many in the user model. This means that it user.connectionsis an instance of a related manager. You should try passing the instance queryset, i.e.:

friends_you_may_know = list(wider_circle.exclude(user_id__in=user.connections.all()))
+4
source

All Articles