diff options
| author | Alex Gaynor <alex.gaynor@rd.io> | 2013-02-20 11:27:32 -0800 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@rd.io> | 2013-02-20 11:27:32 -0800 |
| commit | b55cde054ee7dd22f93c3522a8ddb1d04193bcac (patch) | |
| tree | d2ac4d9a64ea6c0b8fb561492d1cccce89fa4cf7 /docs | |
| parent | cb5545ea2d747e2457221a03e985ef9b4a79ee2e (diff) | |
Added a db_constraint option to ForeignKeys.
This controls whether or not a database level cosntraint is created. This is useful in a few specialized circumstances, but in general should not be used!
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/models/fields.txt | 13 | ||||
| -rw-r--r-- | docs/releases/1.6.txt | 3 |
2 files changed, 16 insertions, 0 deletions
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt index 33ee05dd85..a4ae66d492 100644 --- a/docs/ref/models/fields.txt +++ b/docs/ref/models/fields.txt @@ -1051,6 +1051,19 @@ define the details of how the relation works. The field on the related object that the relation is to. By default, Django uses the primary key of the related object. +.. attribute:: ForeignKey.db_constraint + + Controls whether or not a constraint should be created in the database for + this foreign key. The default is ``True``, and that's almost certainly what + you want; setting this to ``False`` can be very bad for data integrity. + That said, here are some scenarios where you might want to do this: + + * You have legacy data that is not valid. + * You're sharding your database. + + If you use this, accessing a related object that doesn't exist will raise + its ``DoesNotExist`` exception. + .. attribute:: ForeignKey.on_delete When an object referenced by a :class:`ForeignKey` is deleted, Django by diff --git a/docs/releases/1.6.txt b/docs/releases/1.6.txt index 9594481b9f..8f1a4f375e 100644 --- a/docs/releases/1.6.txt +++ b/docs/releases/1.6.txt @@ -85,6 +85,9 @@ Minor features :class:`~django.http.HttpResponsePermanentRedirect` now provide an ``url`` attribute (equivalent to the URL the response will redirect to). +* Added the :attr:`django.db.models.ForeignKey.db_constraint` + option. + Backwards incompatible changes in 1.6 ===================================== |
