Index: django/core/management.py =================================================================== --- django/core/management.py (revision 1929) +++ django/core/management.py (working copy) @@ -53,10 +53,13 @@ def _is_valid_dir_name(s): return bool(re.search(r'^\w+$', s)) -# If the foreign key points to an AutoField, the foreign key should be an -# IntegerField, not an AutoField. Otherwise, the foreign key should be the same -# type of field as the field to which it points. -get_rel_data_type = lambda f: (f.get_internal_type() == 'AutoField') and 'IntegerField' or f.get_internal_type() +# If the foreign key points to an AutoField, a PositiveIntegerField or a +# PositiveSmallIntegerField, the foreign key should be an +# IntegerField, not the reffered field type. Otherwise, the foreign key should +# be the same type of field as the field to which it points. +get_rel_data_type = lambda f: (f.get_internal_type() in \ + ('AutoField', 'PositiveIntegerField', 'PositiveSmallIntegerField')) and 'IntegerField' \ + or f.get_internal_type() def get_sql_create(mod): "Returns a list of the CREATE TABLE SQL statements for the given module."