Index: core/management/sql.py
===================================================================
--- core/management/sql.py      (revision 8138)
+++ core/management/sql.py      (working copy)
@@ -54,7 +54,7 @@
     for app in apps:
         for model in models.get_models(app):
             for f in model._meta.local_fields:
-                if isinstance(f, models.AutoField):
+                if isinstance(f, models.AutoField) or getattr(f, 'auto_field', False):
                     sequence_list.append({'table': model._meta.db_table, 'column': f.column})
                     break # Only one AutoField is allowed per model, so don't bother continuing.
Index: db/models/base.py
===================================================================
--- db/models/base.py   (revision 8138)
+++ db/models/base.py   (working copy)
@@ -140,7 +140,7 @@
             value.contribute_to_class(cls, name)
         else:
             setattr(cls, name, value)
-
+
     def _prepare(cls):
         """
         Creates some methods once self._meta has been populated.
@@ -327,7 +327,7 @@
                 record_exists = False
         if not pk_set or not record_exists:
             if not pk_set:
-                values = [(f, f.get_db_prep_save(raw and getattr(self, f.attname) or f.pre_save(self, True))) for f in meta.local_fields if not isinstance(f, AutoField)]
+                values = [(f, f.get_db_prep_save(raw and getattr(self, f.attname) or f.pre_save(self, True))) for f in meta.local_fields if not isinstance(f, AutoField) and not getattr(f, 'auto_field', False)]
             else:
                 values = [(f, f.get_db_prep_save(raw and getattr(self, f.attname) or f.pre_save(self, True))) for f in meta.local_fields]
Index: db/models/manipulators.py
===================================================================
--- db/models/manipulators.py   (revision 8138)
+++ db/models/manipulators.py   (working copy)
@@ -179,7 +179,7 @@
 
                         if f == related.field:
                             param = getattr(new_object, related.field.rel.get_related_field().attname)
-                        elif (not self.change) and isinstance(f, AutoField):
+                        elif (not self.change) and (isinstance(f, AutoField) or getattr(f, 'auto_field', False)):
                             param = None
                         elif self.change and (isinstance(f, FileField) or not child_follow.get(f.name, None)):
                             if old_rel_obj:
Index: db/models/fields/__init__.py
===================================================================
--- db/models/fields/__init__.py        (revision 8138)
+++ db/models/fields/__init__.py        (working copy)
@@ -82,7 +82,7 @@
             editable=True, serialize=True, unique_for_date=None,
             unique_for_month=None, unique_for_year=None, validator_list=None,
             choices=None, help_text='', db_column=None, db_tablespace=None,
-            auto_created=False):
+            auto_created=False, auto_field=False):
         self.name = name
         self.verbose_name = verbose_name
         self.primary_key = primary_key
@@ -101,6 +101,7 @@
         self._choices = choices or []
         self.help_text = help_text
         self.db_column = db_column
+        self.auto_field = auto_field
         self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
 
         # Set db_index to True if the field has a relationship and doesn't explicitly set db_index.
@@ -199,6 +200,10 @@
         cls._meta.add_field(self)
         if self.choices:
             setattr(cls, 'get_%s_display' % self.name, curry(cls._get_FIELD_display, field=self))
+       if self.auto_field:
+                       assert not cls._meta.has_auto_field, "A model can't have more than one auto_field=True or AutoFields."
+                       cls._meta.has_auto_field = True
+                       cls._meta.auto_field = self
 
     def get_attname(self):
         return self.name
@@ -337,7 +342,7 @@
         # If this field is in a related context, check whether any other fields
         # in the related object have core=True. If so, add a validator --
         # RequiredIfOtherFieldsGiven -- to this FormField.
-        if rel and not self.blank and not isinstance(self, AutoField) and not isinstance(self, FileField):
+        if rel and not self.blank and not isinstance(self, FileField) and not self.auto_field:
             # First, get the core fields, if any.
             core_field_names = []
             for f in opts.fields:
@@ -434,6 +439,8 @@
 
     def formfield(self, form_class=forms.CharField, **kwargs):
         "Returns a django.forms.Field instance for this database Field."
+        if self.auto_field:
+               return None
         defaults = {'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text}
         if self.choices:
             defaults['widget'] = forms.Select(choices=self.get_choices(include_blank=self.blank or not (self.has_default() or 'initial' in kwargs)))
@@ -451,6 +458,7 @@
     def __init__(self, *args, **kwargs):
         assert kwargs.get('primary_key', False) is True, "%ss must have primary_key=True." % self.__class__.__name__
         kwargs['blank'] = True
+        kwargs['auto_field'] = True
         Field.__init__(self, *args, **kwargs)
 
     def to_python(self, value):
@@ -482,12 +490,6 @@
             return None
         return Field.get_manipulator_new_data(self, new_data, rel)
 
-    def contribute_to_class(self, cls, name):
-        assert not cls._meta.has_auto_field, "A model can't have more than one AutoField."
-        super(AutoField, self).contribute_to_class(cls, name)
-        cls._meta.has_auto_field = True
-        cls._meta.auto_field = self
-
     def formfield(self, **kwargs):
         return None 
Index: forms/models.py
===================================================================
--- forms/models.py     (revision 8138)
+++ forms/models.py     (working copy)
@@ -37,7 +37,7 @@
                          " validate." % (opts.object_name, fail_message))
     cleaned_data = form.cleaned_data
     for f in opts.fields:
-        if not f.editable or isinstance(f, models.AutoField) \
+        if not f.editable or isinstance(f, models.AutoField) or f.auto_field \
                 or not f.name in cleaned_data:
             continue
         if fields and f.name not in fields:
@@ -378,8 +378,9 @@
 
     def add_fields(self, form, index):
         """Add a hidden field for the object's primary key."""
-        self._pk_field_name = self.model._meta.pk.attname
-        form.fields[self._pk_field_name] = IntegerField(required=False, widget=HiddenInput)
+        if self.model._meta.has_auto_field:
+            self._pk_field_name = self.model._meta.pk.attname
+            form.fields[self._pk_field_name] = IntegerField(required=False, widget=HiddenInput)
         super(BaseModelFormSet, self).add_fields(form, index)
 
 def modelformset_factory(model, form=ModelForm, formfield_callback=lambda f: f.formfield(),
Index: core/management/sql.py
===================================================================
--- core/management/sql.py      (revision 8138)
+++ core/management/sql.py      (working copy)
@@ -54,7 +54,7 @@
     for app in apps:
         for model in models.get_models(app):
             for f in model._meta.local_fields:
-                if isinstance(f, models.AutoField):
+                if isinstance(f, models.AutoField) or getattr(f, 'auto_field', False):
                     sequence_list.append({'table': model._meta.db_table, 'column': f.column})
                     break # Only one AutoField is allowed per model, so don't bother continuing.
