C
C
Cyber_bober2016-01-29 01:35:44
Django
Cyber_bober, 2016-01-29 01:35:44

How does .all() work on select_related in Django?

Hello, I'm learning about the set.all() function, I can't catch up with how it is formed. Let's say I get records from a category

category = Category.objects.select_related().get(id=id)

and pass them to a variable
books = category.book_set.all()
here the question is, how is set.all() formed? where does the book attribute come from in the books_set code?
Thanks for the help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rostislav Grigoriev, 2016-01-29
@Cyber_bober

where does the book attribute come from in the books_set code?

There is a Book model, hence book_set

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question