[Django]-Django. How to get related_name of a field from the contenttypes framework

6👍

OK, got it. As a reminder, field_name is what I know, it’s hardcoded.

related_name = content_type.model_class().field_name.field.related_query_name()

0👍

Thanks gwaramadze! Here is a similar answer if you have an object:

object._meta.get_field(field_name).related_query_name()

Leave a comment