28
votes

In django, what's the difference between a ManyToOneRel and a ForeignKey field?

2

2 Answers

38
votes

ManyToOneRel is not a django.db.models.fields.Field, it is a class that is used inside Django but not in the user code.

45
votes

Django relations model exposes (and documents) only OneToOneField, ForeignKey and ManyToManyField, which corresponds to the inner

  • OneToOneField -> OneToOneRel
  • ForeignKey -> ManyToOneRel
  • ManyToManyField -> ManyToManyRel

See source of django.db.models.fields.related for further details.