#24289: Is usage of many_to_one and one_to_many terms confusing for relation flags? -------------------------------------+------------------------------------- Reporter: akaariai | Owner: nobody Type: Bug | Status: closed Component: Database layer | Version: 1.8alpha1 (models, ORM) | Severity: Normal | Resolution: invalid Keywords: | Triage Stage: | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by loic):
* cc: loic (added) Comment: I understand that I'm probably wrong because this seems logical to a few people, but I just can't get it for some reason. > ForeignKeys are One-to-many, based on the interpretation that there is "one" value on the side that defines them, and "many" on the other side. > However, it's easy to look at it the other way, and say that a ForeignKey is defining the fact that there where it is defined, it's going to point to "many" objects, and on the other side, it will point to "one" object. Both statements read the same to me, the first one says `"one" value on the side that defines them` the other one says `where it is defined, it's going to point to "many" objects` (i.e. if the side it **points to** is the "many" side, then it is itself the "one" side). From my perspective: {{{ class Employee(Model): company = ForeignKey(to=Company) # many-to-one >>> Employee.objects.first().company <Company: 1> # one-to-many >>> Company.objects.first().employee_set [<Employee: 1>, <Employee: 2>, <Employee: 3>] }}} `Employee` where it is defined points **to** "exactly one object" (`Company`), the reverse field however `Company.employee_set` points **to** "many objects" (all the employees). -- Ticket URL: <https://code.djangoproject.com/ticket/24289#comment:3> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/066.e9d7cc4658d17ed928422b6a45207e6d%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.