Why does model._meta.get_fields() doesn't return reverse relation with _set suffixed

I want to get all fields of a model including reverse fields using _meta.get_fields() but i noticed that some Fields returned are missing the ‘_set’ for reverse relation
Here is an example of 2 models linked with ForeignKey

class Version(models.Model):
    revision = models.ForeignKey(
        help_text="The revision that contains this version.",
        # related_name="version"

class Revision(models.Model):
    date_created = models.DateTimeField(
        verbose_name=_("date created"),
        help_text="The date and time this revision was created.",

    user = models.ForeignKey(
        help_text="The user who created this revision.",

    comment = models.TextField(
        help_text="A text comment on this revision.",

So when i use

(<ManyToOneRel: reversion.version>,
 <django.db.models.fields.AutoField: id>,
 <django.db.models.fields.DateTimeField: date_created>,
 <django.db.models.fields.related.ForeignKey: user>,
 <django.db.models.fields.TextField: comment>)

Out: ‘version’
i think it should be ‘version_set’ because there is no related_name in the ForeignKey

when i do Revision.version i get AttributeError

What is wrong with Revision._meta.get_fields()[0].name? am i missing something

If my understanding is correct, “version” is the related name. For example, that’s what you use as a field reference in a query.

The name “version_set” is a manager that is created for accessing the collection of items referencing the base object, it’s not a field.

You don’t generally reference a version_set object directly - you use it as a manager with a chained function such as .all() to access the members of that list.

In this example “version” is not the related_name. looks, it is commented. as in the original code it was not specified Revision._meta.get_fields()[0].name still return version. so for both cases (related_name set vs related_name not set) get_fields()[0].name is still the same

Sorry, typo on my part - it’s the related_query_name.

But aside from that, the key point here is that the _set suffixed name is not a field, it’s a manager. They’re two different things.