diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py index 17631e15ef..dc7c9b2cea 100644 --- a/django/utils/autoreload.py +++ b/django/utils/autoreload.py @@ -272,7 +272,12 @@ class BaseReloader: from django.urls import get_resolver # Prevent a race condition where URL modules aren't loaded when the # reloader starts by accessing the urlconf_module property. - get_resolver().urlconf_module + try: + get_resolver().urlconf_module + except Exception: + # Loading the urlconf can result in errors during development. + # If this occurs then swallow the error and continue. + pass logger.debug('Apps ready_event triggered. Sending autoreload_started signal.') autoreload_started.send(sender=self) self.run_loop() diff --git a/docs/releases/2.2.1.txt b/docs/releases/2.2.1.txt index 9696488e14..4a2d77aaf3 100644 --- a/docs/releases/2.2.1.txt +++ b/docs/releases/2.2.1.txt @@ -64,3 +64,6 @@ Bugfixes permissions for proxy models if the target permissions already existed. For example, when a permission had been created manually or a model had been migrated from concrete to proxy (:ticket:`30351`). + +* Fixed a regression in Django 2.2 that caused a crash of :djadmin:`runserver` + when URLConf modules raised exceptions (:ticket:`30323`).