Skip to content

Commit

Permalink
Merge 687637a into 844e5f8
Browse files Browse the repository at this point in the history
  • Loading branch information
DAV3HIT3 committed Oct 9, 2014
2 parents 844e5f8 + 687637a commit b961239
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions simple_history/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def python_2_unicode_compatible(klass):

registered_models = {}

nonrel_dbs = ('django_mongodb_engine')


class HistoricalRecords(object):
thread = threading.local()
Expand Down Expand Up @@ -268,7 +270,11 @@ def get_field(self, other, cls):
if isinstance(to_field, models.OneToOneField):
field = self.get_one_to_one_field(to_field, other)
elif isinstance(to_field, models.AutoField):
field.__class__ = models.IntegerField
# Check if AutoField is string for django-non-rel support
if settings.DATABASES['default']['ENGINE'] in nonrel_dbs:
field.__class__ = models.TextField
else:
field.__class__ = models.IntegerField
else:
field.__class__ = to_field.__class__
excluded_prefixes = ("_", "__")
Expand Down Expand Up @@ -322,7 +328,12 @@ def transform_field(field):
if isinstance(field, models.AutoField):
# The historical model gets its own AutoField, so any
# existing one must be replaced with an IntegerField.
field.__class__ = models.IntegerField
if settings.DATABASES['default']['ENGINE'] in nonrel_dbs:
# Check if AutoField is string for django-non-rel support
field.__class__ = models.TextField
else:
field.__class__ = models.IntegerField

elif isinstance(field, models.FileField):
# Don't copy file, just path.
field.__class__ = models.TextField
Expand Down

0 comments on commit b961239

Please sign in to comment.