summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-02-28 13:31:11 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-02-28 13:31:11 +0000
commit7c54780497aafc0749fa3f9e8d77f80e1f7b7d83 (patch)
treeb67079f5419b9f874498802efa2565074d28b285
parenta9008f89283d62f9c424e8d7a0f4bb589c2a7963 (diff)
queryset-refactor: Head off any attempts to use unique_together across inherited models.
We don't support check constraints and triggers, so trying to do this would be optimistic at best. git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7172 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/management/validation.py2
-rw-r--r--docs/model-api.txt4
2 files changed, 6 insertions, 0 deletions
diff --git a/django/core/management/validation.py b/django/core/management/validation.py
index f5e4f7fc70..cd1f84f34b 100644
--- a/django/core/management/validation.py
+++ b/django/core/management/validation.py
@@ -232,5 +232,7 @@ def get_validation_errors(outfile, app=None):
else:
if isinstance(f.rel, models.ManyToManyRel):
e.add(opts, '"unique_together" refers to %s. ManyToManyFields are not supported in unique_together.' % f.name)
+ if f not in opts.local_fields:
+ e.add(opts, '"unique_together" refers to %s. This is not in the same model as the unique_together statement.' % f.name)
return len(e.errors)
diff --git a/docs/model-api.txt b/docs/model-api.txt
index 1926495728..abf69835be 100644
--- a/docs/model-api.txt
+++ b/docs/model-api.txt
@@ -1166,6 +1166,10 @@ together. It's used in the Django admin and is enforced at the database
level (i.e., the appropriate ``UNIQUE`` statements are included in the
``CREATE TABLE`` statement).
+All the fields specified in ``unique_together`` must be part of the current
+model. If you are using `model inheritance`_, you cannot refer to fields from
+any parent classes in ``unique_together``.
+
**New in Django development version**
For convenience, unique_together can be a single list when dealing