Helpers
Pluralize UIModule
- class usernado.helpers.Pluralize(handler: RequestHandler)
Pluralize a string based on a value.
You Must set
Pluralizeas a valid UIModule Inui_modulessetting like soui_modules=dict('pluralize': Pluralize)
and then use this uimoduele in templates like so
{% module pluralize(post, post_counts) %}
humanize decorator
- @usernado.helpers.humanize(func: Callable[[...], Any]) Callable[[...], Any]
Humanize datetime in templates.
To use
humanizeyou have to create a DateTimeField in your model then create a method in your model decorated withhumanizelike so@humanize def diff_for_humans(self): return self.created_at
then use
humanizein your templates like so:{{ obj.diff_for_humans() }}
api_route decorator
- @usernado.helpers.api_route(url: str, name: Optional[str] = None) Callable[[...], Any]
Usernado API router class.
You can decorate APIHandler inherited classes with
api_routedecorator.See also
For further information take a look at examples