Ticket #6346: url.diff
File url.diff, 1.6 KB (added by , 17 years ago) |
---|
-
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: … … 1047 1064 if '=' in arg: 1048 1065 k, v = arg.split('=', 1) 1049 1066 k = k.strip() 1050 kwargs[k] = parser.compile_filter(v)1067 kwargs[k] = v 1051 1068 else: 1052 args.append( parser.compile_filter(arg))1069 args.append(arg) 1053 1070 return URLNode(bits[1], args, kwargs) 1054 1071 url = register.tag(url) 1055 1072