Skip to content
Browse files

Override urlconf_module so that Django system checks don't crash. (#…


* Add a test case for #6717.

* Override urlconf_module so that Django system checks don't crash.

Without this fix, Django system checks in Django 2.2 will try to resolve the
"app_resolver" module, which does not exist. Overriding ``urlconf_module``
prevents the issue.

Fixes #6717
  • Loading branch information...
lddubeau authored and FinalAngel committed Aug 27, 2019
1 parent 31d1295 commit efbeaa0be5f9cac12d51ffdbca7716a01a68740a
Showing with 26 additions and 6 deletions.
  1. +14 −6 cms/
  2. +12 −0 cms/tests/
@@ -59,20 +59,28 @@ def applications_page_check(request, current_page=None, path=None):
return None

class AppRegexURLResolver(URLResolver):

def __init__(self, *args, **kwargs):
self.page_id = None
self.url_patterns_dict = {}
super(AppRegexURLResolver, self).__init__(*args, **kwargs)

def urlconf_module(self):
# It is valid for urlconf_module to be a list of patterns. So we just
# return the list here.
# See
return self.url_patterns_dict.get(get_language(), [])

# On URLResolver the url_patterns property is cached and thus calls made after
# language changes (different return values for get_language()) would not return the
# right value. Overriding here prevents caching.
def url_patterns(self):
language = get_language()
if language in self.url_patterns_dict:
return self.url_patterns_dict[language]
return []
return self.urlconf_module

def resolve_page_id(self, path):
"""Resolves requested path similar way how resolve does, but instead
@@ -7,6 +7,7 @@
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site
from django.core import checks
from django.core.cache import cache
from django.test.utils import override_settings
from django.urls import NoReverseMatch, clear_url_caches, resolve, reverse
@@ -173,6 +174,17 @@ def test_apphook_on_homepage(self):


def test_apphook_does_not_crash_django_checks(self):
# This test case reproduced the situation causing the error reported in issue #6717.
superuser = get_user_model().objects.create_superuser('admin', '', 'admin')
create_page("apphooked-page", "nav_playground.html", "en",
created_by=superuser, published=True, apphook="SampleApp")

def test_apphook_on_root_reverse(self):

0 comments on commit efbeaa0

Please sign in to comment.
You can’t perform that action at this time.