Answer the question
In order to leave comments, you need to log in
How to get an additional object ( QuerySet )?
For example, I get a list of who the user is following:
user = User.objects.get(id=1)
subscriptions = Subscription.objects.filter(user=user)
[
{
"id": 1,
"user": 1 (User object),
"author": 2 (User object)
}
]
recipes = subscriptions[0].author.recipes.all()
[
{
"id": 1,
"user": 1,
"author": 2,
"recipes": [
{
"id": 1,
"name": "Name"
}
]
}
]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question