Opened 8 years ago

Last modified 8 years ago

#28129 closed New feature

Custom template tag keyword only arguments — at Initial Version

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

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

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top