Ticket #12906: allow_variable_in_url_templatetag.diff
File allow_variable_in_url_templatetag.diff, 1.6 KB (added by , 15 years ago) |
---|
-
django/template/defaulttags.py
old new 366 366 kwargs = dict([(smart_str(k,'ascii'), v.resolve(context)) 367 367 for k, v in self.kwargs.items()]) 368 368 369 # Try to resolve view_name as Variable, failing silently. 370 try: 371 view_name = Variable(self.view_name).resolve(context) 372 except VariableDoesNotExist: 373 view_name = self.view_name 374 369 375 # Try to look up the URL twice: once given the view name, and again 370 376 # relative to what we guess is the "main" app. If they both fail, 371 377 # re-raise the NoReverseMatch unless we're using the 372 378 # {% url ... as var %} construct in which cause return nothing. 373 379 url = '' 374 380 try: 375 url = reverse( self.view_name, args=args, kwargs=kwargs, current_app=context.current_app)381 url = reverse(view_name, args=args, kwargs=kwargs, current_app=context.current_app) 376 382 except NoReverseMatch, e: 377 383 if settings.SETTINGS_MODULE: 378 384 project_name = settings.SETTINGS_MODULE.split('.')[0] 379 385 try: 380 url = reverse(project_name + '.' + self.view_name,386 url = reverse(project_name + '.' + view_name, 381 387 args=args, kwargs=kwargs, current_app=context.current_app) 382 388 except NoReverseMatch: 383 389 if self.asvar is None: