Skip to content

Commit

Permalink
Merge pull request #5012 from divio/fix/urlconf-during-startup
Browse files Browse the repository at this point in the history
catch db not ready for all models
  • Loading branch information
yakky committed Feb 17, 2016
2 parents e104d0d + 9027745 commit 94faefc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cms/appresolver.py
Expand Up @@ -191,6 +191,16 @@ def get_patterns_for_title(path, title):


def get_app_patterns():
try:
return _get_app_patterns()
except (OperationalError, ProgrammingError):
# ignore if DB is not ready
# Starting with Django 1.9 this code gets called even when creating
# or running migrations. So in many cases the DB will not be ready yet.
return []


def _get_app_patterns():
"""
Get a list of patterns for all hooked apps.
Expand All @@ -211,9 +221,6 @@ def get_app_patterns():
current_site = Site.objects.get_current()
except Site.DoesNotExist:
current_site = None
except (OperationalError, ProgrammingError):
# ignore if DB is not ready
return []
included = []

# we don't have a request here so get_page_queryset() can't be used,
Expand Down

0 comments on commit 94faefc

Please sign in to comment.