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()
- [Django]-Django: Best way for simple hierarchy?
- [Django]-Django, how to use render_to_response with many templates
- [Django]-Preview the photo after selecting the file in Django
Source:stackexchange.com