Opened 9 years ago
Last modified 9 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 )
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'
Note:
See TracTickets
for help on using tickets.