#28129: Custom template tag keyword only arguments
-------------------------------------+-------------------------------------
Reporter: Alexander | Owner: nobody
Allakhverdiyev |
Type: Bug | Status: new
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: template,inspect | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Alexander Allakhverdiyev:
Old description:
> 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
> {{{
> ValueError: Function has keyword-only arguments or annotations, use
> getfullargspec() API which can support them
> }}}
>
> Proposed solution: use getfullargspec instead of getargspec in
> templates/base.py
New description:
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'
}}}
--
--
Ticket URL: <https://code.djangoproject.com/ticket/28129#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.3fa05eb4b605605bd5abd9292df4b2e5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.