Difference between ManyToOneRel and ForeignKey?

Question:

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

Asked By: sfendell

||

Answers:

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

Answered By: wRAR

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.

Answered By: Yauhen Yakimovich
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.