Skip to content

One-to-Many #103

Answered by collerek
Erhannis asked this question in Q&A
Feb 16, 2021 · 3 comments · 4 replies
Discussion options

You must be logged in to vote

Re.1 Ok I get your way of thinking, but you would like to just define the relation from other side or some kind of table linking like you described in Java?

Re.2 You can, but remember that even if one side of the relation will have one model, so the link is many to one, both sides will return a list on access. So for one model it will be always one element list.

Re.5. Yes you can go deep down with select_related, you use double underscore in list of joins so when you select from thing in your example you can select_related("other_things__more_things") with relation names.

As for the list of relations there actually is a method extract_related_names that returns a set of all field names wi…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@Erhannis
Comment options

Comment options

You must be logged in to vote
1 reply
@Erhannis
Comment options

Comment options

You must be logged in to vote
2 replies
@Erhannis
Comment options

@collerek
Comment options

Answer selected by Erhannis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants