@@ -53,6 +53,8 @@ def python_2_unicode_compatible(klass):
53
53
54
54
registered_models = {}
55
55
56
+ nonrel_dbs = ('django_mongodb_engine' )
57
+
56
58
57
59
class HistoricalRecords (object ):
58
60
thread = threading .local ()
@@ -265,11 +267,11 @@ def get_field(self, other, cls):
265
267
if isinstance (to_field , models .OneToOneField ):
266
268
field = self .get_one_to_one_field (to_field , other )
267
269
elif isinstance (to_field , models .AutoField ):
268
- # Check if AutoField is string for django-non-rel support
269
- if isinstance ( field , models . TextField ) :
270
- field .__class__ = models .TextField
271
- else :
272
- field .__class__ = models .IntegerField
270
+ # Check if AutoField is string for django-non-rel support
271
+ if settings . DATABASES [ 'default' ][ 'ENGINE' ] in nonrel_dbs :
272
+ field .__class__ = models .TextField
273
+ else :
274
+ field .__class__ = models .IntegerField
273
275
else :
274
276
field .__class__ = to_field .__class__
275
277
excluded_prefixes = ("_" , "__" )
@@ -323,11 +325,11 @@ def transform_field(field):
323
325
if isinstance (field , models .AutoField ):
324
326
# The historical model gets its own AutoField, so any
325
327
# existing one must be replaced with an IntegerField.
326
- if isinstance ( field , models . TextField ) :
327
- # Check if AutoField is string for django-non-rel support
328
- field .__class__ = models .TextField
329
- else :
330
- field .__class__ = models .IntegerField
328
+ if settings . DATABASES [ 'default' ][ 'ENGINE' ] in nonrel_dbs :
329
+ # Check if AutoField is string for django-non-rel support
330
+ field .__class__ = models .TextField
331
+ else :
332
+ field .__class__ = models .IntegerField
331
333
332
334
elif isinstance (field , models .FileField ):
333
335
# Don't copy file, just path.
0 commit comments