Ticket #6346: url_patch.diff
File url_patch.diff, 2.2 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: 365 try: 366 project_name = settings.SETTINGS_MODULE.split('.')[0] 367 return reverse(project_name + '.' + self.view_name, 368 args=args, kwargs=kwargs) 369 except NoReverseMatch: 370 return '' 382 project_name = settings.SETTINGS_MODULE.split('.')[0] 383 return reverse(project_name + '.' + self.view_name, 384 args=args, kwargs=kwargs) 371 385 372 386 class WidthRatioNode(Node): 373 387 def __init__(self, val_expr, max_expr, max_width): … … 1047 1061 if '=' in arg: 1048 1062 k, v = arg.split('=', 1) 1049 1063 k = k.strip() 1050 kwargs[k] = parser.compile_filter(v)1064 kwargs[k] = v 1051 1065 else: 1052 args.append( parser.compile_filter(arg))1066 args.append(arg) 1053 1067 return URLNode(bits[1], args, kwargs) 1054 1068 url = register.tag(url) 1055 1069