Helpers

Pluralize UIModule

class usernado.helpers.Pluralize(handler: RequestHandler)

Pluralize a string based on a value.

You Must set Pluralize as a valid UIModule In ui_modules setting like so

ui_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 humanize you have to create a DateTimeField in your model then create a method in your model decorated with humanize like so

@humanize
def diff_for_humans(self):
    return self.created_at

then use humanize in 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_route decorator.

See also

For further information take a look at examples