Ticket #6346: url_patch.2.diff
File url_patch.2.diff, 2.0 KB (added by , 17 years ago) |
---|
-
django/template/defaulttags.py
old new 356 356 357 357 def render(self, context): 358 358 from django.core.urlresolvers import reverse, NoReverseMatch 359 args = [arg.resolve(context) for arg in self.args] 360 kwargs = dict([(smart_str(k,'ascii'), v.resolve(context)) 361 for k, v in self.kwargs.items()]) 359 args = [] 360 for arg in self.args: 361 if arg[0] in ["'", '"'] and arg[0] == arg[-1]: 362 arg = arg[1:-1] 363 else: 364 try: 365 arg = Variable(arg).resolve(context) 366 except VariableDoesNotExist: 367 pass 368 args.append(arg) 369 kwargs = {} 370 for k, v in self.kwargs.items(): 371 if v[0] in ["'", '"'] and v[0] == v[-1]: 372 v = v[1:-1] 373 else: 374 try: 375 v = Variable(v).resolve(context) 376 except VariableDoesNotExist: 377 pass 378 kwargs[smart_str(k,'ascii')] = v 362 379 try: 363 380 return reverse(self.view_name, args=args, kwargs=kwargs) 364 381 except NoReverseMatch: … … 367 384 return reverse(project_name + '.' + self.view_name, 368 385 args=args, kwargs=kwargs) 369 386 except NoReverseMatch: 370 return '' 387 if settings.TEMPLATE_DEBUG: 388 raise 389 else: 390 return '' 371 391 372 392 class WidthRatioNode(Node): 373 393 def __init__(self, val_expr, max_expr, max_width): … … 1047 1067 if '=' in arg: 1048 1068 k, v = arg.split('=', 1) 1049 1069 k = k.strip() 1050 kwargs[k] = parser.compile_filter(v)1070 kwargs[k] = v 1051 1071 else: 1052 args.append( parser.compile_filter(arg))1072 args.append(arg) 1053 1073 return URLNode(bits[1], args, kwargs) 1054 1074 url = register.tag(url) 1055 1075