Last active
September 26, 2021 02:20
-
-
Save FZambia/5059233 to your computer and use it in GitHub Desktop.
reload django urlconf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#python manage.py runserver --noreload | |
from django.conf.urls import patterns, include, url | |
from django.conf import settings | |
from django.http import HttpResponse | |
import sys | |
def reload_urls(request, urlconf=None): | |
if urlconf is None: | |
urlconf = settings.ROOT_URLCONF | |
if urlconf in sys.modules: | |
reload(sys.modules[urlconf]) | |
return HttpResponse('urlconf reloaded') | |
def reloaded(request): | |
return HttpResponse('hello') | |
urlpatterns = patterns('', | |
url(r'^$', reload_urls), | |
url(r'^reloaded/$', reloaded), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment