Opened 20 months ago

Closed 20 months ago

Last modified 20 months 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


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).

Change History (2)

comment:1 Changed 20 months ago by Timothée Mazzucotelli

Resolution: invalid
Status: newclosed

comment:2 Changed 20 months ago by Timothée Mazzucotelli

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