Skip to content

Instantly share code, notes, and snippets.

@anentropic
Created July 29, 2014 10:24
Show Gist options
  • Save anentropic/9ac47f6518c88fa8d2b0 to your computer and use it in GitHub Desktop.
Save anentropic/9ac47f6518c88fa8d2b0 to your computer and use it in GitHub Desktop.
reload Django urlconf
def reload_urlconf(urlconf=None, urls_attr='urlpatterns'):
if urlconf is None:
urlconf = settings.ROOT_URLCONF
if urlconf in sys.modules:
reload(sys.modules[urlconf])
reloaded = import_module(urlconf)
reloaded_urls = getattr(reloaded, urls_attr)
set_urlconf(tuple(reloaded_urls))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment