Skip to content

Commit

Permalink
Version 1.3b7 - fixes registration when there is no app config
Browse files Browse the repository at this point in the history
  • Loading branch information
coordt committed Jun 9, 2015
1 parent e841de7 commit 02780ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion categories/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'minor': 3,
'micro': 0,
'releaselevel': 'beta',
'serial': 6
'serial': 7
}


Expand Down
9 changes: 5 additions & 4 deletions categories/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,21 @@ def register_model(self, app, model_name, field_type, field_definitions):
from django.apps import apps
import collections

app_config = apps.get_app_config(app)
app_label = app_config.label
app_label = app

if isinstance(field_definitions, basestring):
field_definitions = [field_definitions]
elif not isinstance(field_definitions, collections.Iterable):
raise ImproperlyConfigured(_('Field configuration for %(app)s should '
'be a string or iterable') % {'app': app_config.label})
'be a string or iterable') % {'app': app})

if field_type not in ('ForeignKey', 'ManyToManyField'):
raise ImproperlyConfigured(_('`field_type` must be either `"ForeignKey"` or `"ManyToManyField"`.'))

try:
if not hasattr(model_name, "_meta"):
app_config = apps.get_app_config(app)
app_label = app_config.label
model = app_config.get_model(model_name)
else:
model = model_name
Expand Down Expand Up @@ -77,7 +78,7 @@ def register_model(self, app, model_name, field_type, field_definitions):
'settings': 'CATEGORY_SETTINGS',
'app': app,
'model': model_name})
registry_name = ".".join([app_config.label, model_name.lower(), field_name])
registry_name = ".".join([app_label, model_name.lower(), field_name])
if registry_name in self._field_registry:
continue

Expand Down

0 comments on commit 02780ba

Please sign in to comment.