1 2 3 4 5 6 7 8 9 10 | from django import template
@register.filter
def nice_name(user):
"""
Example::
Hi, {{ user|nice_name }}
"""
return user.get_full_name() or user.username
|
More like this
- Show users' full names for foreign keys in admin by SmileyChris 3 years, 10 months ago
- Boolean Image Flag TemplateTag by MichaelAnckaert 4 years, 5 months ago
- URL based breadcrumbs by phlex 5 years, 2 months ago
- EasyFeed class by limodou 6 years, 2 months ago
- More information about users and groups in user admin by buriy 4 years, 10 months ago
Comments
Why not simply use
{{ user.get_full_name|default:user.username }}?#