Answer the question
In order to leave comments, you need to log in
How to get a list of related entities from a model in Django?
Hello!
In the code, I got the Worker model (worker). An employee has nested entities such as place of work, address, and so on. (one-to-many relationship) Can I get a list of these related entities from the Worker model. It is with one-to-many connections. Tried through model._meta.related_objects, but there are also entities with other relationships in the list.
Answer the question
In order to leave comments, you need to log in
The fields you can get from _meta.get_fields() have boolean fields: is_relation, one_to_one, many_to_one, one_to_many, many_to_many.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question