Ticket #10745: url-tag-variable-view-name.diff

File url-tag-variable-view-name.diff, 1.2 KB (added by Soviut, 16 years ago)

patch proposal

  • django/template/defaulttags.py

     
    352352
    353353class URLNode(Node):
    354354    def __init__(self, view_name, args, kwargs, asvar):
    355         self.view_name = view_name
     355        self.view_name = Variable(view_name)
    356356        self.args = args
    357357        self.kwargs = kwargs
    358358        self.asvar = asvar
     
    369369        # {% url ... as var %} construct in which cause return nothing.
    370370        url = ''
    371371        try:
    372             url = reverse(self.view_name, args=args, kwargs=kwargs)
     372            url = reverse(self.view_name.resolve(context), args=args, kwargs=kwargs)
    373373        except NoReverseMatch, e:
    374374            if settings.SETTINGS_MODULE:
    375375                project_name = settings.SETTINGS_MODULE.split('.')[0]
    376376                try:
    377                     url = reverse(project_name + '.' + self.view_name,
     377                    url = reverse(project_name + '.' + self.view_name.resolve(context),
    378378                              args=args, kwargs=kwargs)
    379379                except NoReverseMatch:
    380380                    if self.asvar is None:
Back to Top