Code

Ticket #12132: patch.diff

File patch.diff, 588 bytes (added by Mark, 5 years ago)

Proposed fix

Line 
1Index: django/db/models/base.py
2===================================================================
3--- django/db/models/base.py    (revision 11706)
4+++ django/db/models/base.py    (working copy)
5@@ -641,7 +641,7 @@
6         # the list of checks. Again, skip empty fields and any that did not validate.
7         for f in self._meta.fields:
8             name = f.name
9-            if f.unique:
10+            if f.unique and not f.primary_key:
11                 unique_checks.append((name,))
12             if f.unique_for_date:
13                 date_checks.append(('date', name, f.unique_for_date))