Ticket #1165: djangopatch

File djangopatch, 1.1 KB (added by avandorp@…, 18 years ago)

Proposed patch

Line 
1Index: django/core/management.py
2===================================================================
3--- django/core/management.py (revision 1929)
4+++ django/core/management.py (working copy)
5@@ -53,10 +53,13 @@
6 def _is_valid_dir_name(s):
7 return bool(re.search(r'^\w+$', s))
8
9-# If the foreign key points to an AutoField, the foreign key should be an
10-# IntegerField, not an AutoField. Otherwise, the foreign key should be the same
11-# type of field as the field to which it points.
12-get_rel_data_type = lambda f: (f.get_internal_type() == 'AutoField') and 'IntegerField' or f.get_internal_type()
13+# If the foreign key points to an AutoField, a PositiveIntegerField or a
14+# PositiveSmallIntegerField, the foreign key should be an
15+# IntegerField, not the reffered field type. Otherwise, the foreign key should
16+# be the same type of field as the field to which it points.
17+get_rel_data_type = lambda f: (f.get_internal_type() in \
18+ ('AutoField', 'PositiveIntegerField', 'PositiveSmallIntegerField')) and 'IntegerField' \
19+ or f.get_internal_type()
20
21 def get_sql_create(mod):
22 "Returns a list of the CREATE TABLE SQL statements for the given module."
Back to Top