Skip to content

Instantly share code, notes, and snippets.

@FZambia
Last active September 26, 2021 02:20
Show Gist options
  • Save FZambia/5059233 to your computer and use it in GitHub Desktop.
Save FZambia/5059233 to your computer and use it in GitHub Desktop.
reload django urlconf
#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