Ticket #3530: urlresolvers_reverse_urlconf_func.diff
File urlresolvers_reverse_urlconf_func.diff, 1.0 KB (added by , 17 years ago) |
---|
-
django/core/urlresolvers.py
291 291 def resolve(path, urlconf=None): 292 292 return get_resolver(urlconf).resolve(path) 293 293 294 def urlconf_func(): 295 from django.conf import settings 296 if not hasattr(settings, 'DYNAMIC_URLCONF_FUNCTION'): 297 return None 298 try: 299 mod_name, func_name = get_mod_func(getattr(settings, 'DYNAMIC_URLCONF_FUNCTION')) 300 return getattr(__import__(mod_name, {}, {}, ['']), func_name) 301 except Exception, e: 302 raise ImproperlyConfigured, "Error while importing DYNAMIC_URLCONF_FUNCTION from settings.py: %s" % (e) 303 urlconf_func = urlconf_func() 304 294 305 def reverse(viewname, urlconf=None, args=None, kwargs=None): 306 if urlconf_func and urlconf is None: 307 urlconf = urlconf_func() 295 308 args = args or [] 296 309 kwargs = kwargs or {} 297 310 return iri_to_uri(u'/' + get_resolver(urlconf).reverse(viewname, *args, **kwargs)) 298