Opened 8 years ago

Last modified 8 years ago

#28129 closed New feature

Custom template tag keyword only arguments — at Version 1

Reported by: Alexander Allakhverdiyev Owned by: nobody
Component: Template system Version: dev
Severity: Normal Keywords: template, inspect
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Alexander Allakhverdiyev)

Example tag with a keyword-only argument

@register.simple_tag(takes_context=True)
def my_tag(context, arg1, *, kwarg2='n/a'):
    return ''

Html code

<div>bla bla bla</div>
{% my_tag 'arg_1_value' kwarg_2='kwarg_value' %}

Result

django.template.exceptions.TemplateSyntaxError: 'my_tag' received unexpected keyword argument 'kwarg_2'

Change History (1)

comment:1 by Alexander Allakhverdiyev, 8 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top