[Django]-Dynamically reload the URLConfs for a running site


Your question starts from a premise that most Django programmers wouldn’t accept: that you can or should create URLs dynamically from the database. If you’re doing that, you’re doing it wrong.

Your URL patterns are part of the code, not the data. Obviously, the URLs themselves are formed by combining the patterns with the data – eg foo/<slug>/bar/, but this doesn’t need reloading when new slugs are added because it is resolved by the view, not the URL processor.


import sys    
from django.conf import settings
from django.core.urlresolvers import clear_url_caches


Leave a comment