[Answered ]-Wrong GenericForeignKey name in _meta.get_all_field_names()

1👍

A GenericForeignKey uses two fields behind the scenes; in this case they are content_type and object_id since those are the default names. second was created by the GenericRelation on Second.r.

1👍

https://django-model-internals-reference.readthedocs.org/en/latest/get_all_field_names.html

get_all_field_names
Returns a list of all field names that are
possible for this model (including reverse relation names). This is
used for pretty printing debugging output (a list of choices), so any
internal-only field names are not included.

In this case, the reverse relation name is second. Yes, expected behavior.

👤000

Leave a comment