Skip to content

Commit

Permalink
TranslationField: treat empty strings as NULL
Browse files Browse the repository at this point in the history
This avoids Django admin attempting to validate them for uniqueness.
  • Loading branch information
acdha committed Jun 10, 2010
1 parent 9d195af commit e95d5cf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modeltranslation/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ def pre_save(self, model_instance, add):
model_instance.__dict__[self.translated_field.name] = val
return val

def get_db_prep_value(self, value, connection, prepared=False):
if value == "":
return None
else:
return value

def get_internal_type(self):
return self.translated_field.get_internal_type()

Expand Down

0 comments on commit e95d5cf

Please sign in to comment.