Skip to content

Commit

Permalink
Fix bug in django field.
Browse files Browse the repository at this point in the history
  • Loading branch information
Warren Smith committed Nov 28, 2016
1 parent a923b3c commit fc710a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from setuptools import setup, find_packages

__version__ = "0.1.2"
__version__ = "0.1.3"


def file_read(filename):
Expand Down
11 changes: 8 additions & 3 deletions staticmodel/django/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,14 @@ def get_prep_value(self, member):
getattr(member, self._value_field_name))

def to_python(self, db_value):
return self._static_model.members.get(**{
self._value_field_name: super(StaticModelFieldMixin, self).to_python(
db_value)})
super_value = super(StaticModelFieldMixin, self).to_python(db_value)
if super_value is None:
return None
elif super_value == '':
return ''
else:
return self._static_model.members.get(
**{self._value_field_name: super_value})


class StaticModelCharField(
Expand Down

0 comments on commit fc710a6

Please sign in to comment.