Skip to content

Commit

Permalink
fix code for app_label.
Browse files Browse the repository at this point in the history
don't use get_app unless actually needed (may code weird cyclic imports in some cases otherwise), and use '%.models' upfront.
  • Loading branch information
dnozay committed May 15, 2013
1 parent ddede10 commit a683075
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions simple_history/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ def create_history_model(self, model):
"""
attrs = {'__module__': self.module}

app_module = models.get_app(model._meta.app_label)
app_module = '%s.models' % model._meta.app_label
if model.__module__ != self.module:
# registered under different app
attrs['__module__'] = self.module
elif app_module.__name__ != self.module:
elif app_module != self.module:
# has meta options with app_label
attrs['__module__'] = app_module.__name__
app = models.get_app(model._meta.app_label)
attrs['__module__'] = app.__name__ # full dotted name

fields = self.copy_fields(model)
attrs.update(fields)
Expand Down

0 comments on commit a683075

Please sign in to comment.