Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#26892 closed Cleanup/optimization (invalid)

Add documentation about db_constraint for FK and M2M in Multiple Databases section

Reported by: Timothée Mazzucotelli Owned by: nobody
Component: Documentation Version: 1.9
Severity: Normal Keywords: fk m2m db_constraint doc
Cc: timothee.mazzucotelli@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Working on a project that uses several databases, I have searched for a long time the best way to have "fake" or "cross-db" foreign keys between tables that are not on the same database.

I was very surprised when I recently heard about the db_constraint attribute in model fields ForeignKey and ManyToManyField, and wondered why I have found so many ugly hacks before this very Django feature.

Documentation in the Multiple Databases section was very useful, but it would have been a lot more if db_constraint was mentioned in it. And a link back to Multiple Databases from ForeignKey and ManyToManyField db_constraint in model fields reference would also be great.

In don't know when db_constraint appeared but this modification should of course apply to each concerned version of Django (I know 1.8 and following are).

https://docs.djangoproject.com/en/1.9/topics/db/multi-db/
https://docs.djangoproject.com/en/1.9/ref/models/fields/#django.db.models.ForeignKey.db_constraint
https://docs.djangoproject.com/en/1.9/ref/models/fields/#django.db.models.ManyToManyField.db_constraint

Change History (2)

comment:1 by Timothée Mazzucotelli, 8 years ago

Resolution: invalid
Status: newclosed

comment:2 by Timothée Mazzucotelli, 8 years ago

Actually db_constraint is not meant to allow relationships between tables that are not on the same database. Instead it just tells not to set database constraint. So I closed this ticket as invalid.

Note: See TracTickets for help on using tickets.
Back to Top