Skip to content

Functions missing (like precisedelta) and no args possible (because implemented as filters not tags) #2

@bernd-wechner

Description

@bernd-wechner

Thanks all the same for the inspiration and the wonderful start to this (though the Pyi repo has a very broken readme (raw Markdown).

Just a heads up that dropping this little snipped int templatetags/humanize.py in your project provides more and better access to the humanize package:

from django import template
import humanize

register = template.Library()

# registers all humanize functions as template tags
for funcname in [name for name in dir(humanize) if callable(getattr(humanize, name))]:
    func = getattr(humanize, funcname)
    register.simple_tag(func, False, funcname)

which is clearly based on your ideas for which I am grateful and the insight the delivered. Thumbs up. But I do think this is better implemented as a simple code snippet than a python package, as it also provides the insight into how to add any package's functions as template tags.

You've done a great job here though and big thumbs up!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions