Skip to content

Commit

Permalink
Merge pull request #90 from dhui/pythonic
Browse files Browse the repository at this point in the history
Use getattr() instead of hasattr() since it does one less lookup.
  • Loading branch information
bradjasper committed Aug 14, 2014
2 parents 07ec9b1 + 1663621 commit b0b1ae4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion jsonfield/fields.py
Expand Up @@ -72,7 +72,7 @@ def pre_init(self, value, obj):
# Make sure the primary key actually exists on the object before
# checking if it's empty. This is a special case for South datamigrations
# see: https://github.com/bradjasper/django-jsonfield/issues/52
if hasattr(obj, "pk") and obj.pk is not None:
if getattr(obj, "pk", None) is not None:
if isinstance(value, six.string_types):
try:
return json.loads(value, **self.load_kwargs)
Expand Down

0 comments on commit b0b1ae4

Please sign in to comment.