From b3e182faba4a45ae617509bc5e15fd0b8e096e9a Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sun, 15 Dec 2013 11:29:24 +0100 Subject: [PATCH] Fixed incorrect decrementation of nesting_level. Thanks Florian for catching this mistake. --- django/apps/cache.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/django/apps/cache.py b/django/apps/cache.py index 4d1c75dd5b..e91804d6ac 100644 --- a/django/apps/cache.py +++ b/django/apps/cache.py @@ -114,7 +114,6 @@ class BaseAppCache(object): try: models_module = import_module('%s.%s' % (app_name, MODELS_MODULE_NAME)) except ImportError: - self.nesting_level -= 1 # If the app doesn't have a models module, we can just swallow the # ImportError and return no models for this app. if not module_has_submodule(app_module, MODELS_MODULE_NAME): @@ -132,8 +131,8 @@ class BaseAppCache(object): return else: raise - - self.nesting_level -= 1 + finally: + self.nesting_level -= 1 app_config = AppConfig( name=app_name, app_module=app_module, models_module=models_module)