Skip to content

Instantly share code, notes, and snippets.

@loic
Created August 8, 2013 09:51
Show Gist options
  • Select an option

  • Save loic/6183305 to your computer and use it in GitHub Desktop.

Select an option

Save loic/6183305 to your computer and use it in GitHub Desktop.
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index fb4cbbb..029b0ee 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -677,8 +677,9 @@ class AutoField(Field):
}
def __init__(self, *args, **kwargs):
- assert kwargs.get('primary_key', False) is True, \
- "%ss must have primary_key=True." % self.__class__.__name__
+ assert kwargs.get('primary_key', True) is True, \
+ "%ss must have primary_key=True." % self.__class__.__name__
+ kwargs['primary_key'] = True
kwargs['blank'] = True
Field.__init__(self, *args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment