Ticket #10980: url_tag_dynamic_viewnames.patch

File url_tag_dynamic_viewnames.patch, 1.2 KB (added by jflatow@…, 16 years ago)

Patch to implement described behavior

  • defaulttags.py

     
    378378        # re-raise the NoReverseMatch unless we're using the
    379379        # {% url ... as var %} construct in which cause return nothing.
    380380        url = ''
     381        view_name = self.view_name.resolve(context)
    381382        try:
    382             url = reverse(self.view_name, args=args, kwargs=kwargs)
     383            url = reverse(view_name, args=args, kwargs=kwargs)
    383384        except NoReverseMatch:
    384385            project_name = settings.SETTINGS_MODULE.split('.')[0]
    385386            try:
    386                 url = reverse(project_name + '.' + self.view_name,
     387                url = reverse(project_name + '.' + view_name,
    387388                              args=args, kwargs=kwargs)
    388389            except NoReverseMatch:
    389390                if self.asvar is None:
     
    11011102    if len(bits) < 2:
    11021103        raise TemplateSyntaxError("'%s' takes at least one argument"
    11031104                                  " (path to a view)" % bits[0])
    1104     viewname = bits[1]
     1105    viewname = parser.compile_filter(bits[1])
    11051106    args = []
    11061107    kwargs = {}
    11071108    asvar = None
Back to Top