Skip to main content

Add localization support for user's fullname.

Project description

django-fullname-localization

Add localization support for user's fullname.

Install

pip install django-fullname-localization

Settings

pro/settings.py

INSTALLED_APPS = [
    ...
    'django_fullname_localization',
    ...
]

USE_FULL_NAME_INSTEAD_OF_SHORT_NAME = True
FULL_NAME_TEMPLATE = "{user.last_name}{user.first_name}"

Note:

  • At django_fullname_localization app ready step, we override AbstractUser.get_full_name method, so that all user model that inherit from AbstractUser will get a new *.get_full_name() method.
  • Use FULL_NAME_TEMPLATE to define your fullname style.
  • USE_FULL_NAME_INSTEAD_OF_SHORT_NAME defaults to True, so that the short name will be replaced with our full name. Mostly our full name is short enough ^_^

Fullname template setting

FULL_NAME_TEMPLATE default to "{user.last_name}{user.first_name}", it's our default name format ^_^.

Notes:

  • If using default User model, you can use user.first_name and user.last_name parameter to write your own template.
  • If using customer model that has more name parts, you can using parameter {user.your_own_field}.
  • Some application that doesn't override the default User model but keep the full name in first_name and keep the last name in last_name, so that you just set FULL_NAME_TEMPLATE="{user.first_name}".

Usage

app/template/demo.html

{{request.user.get_full_name}}

app/views.py

def page(request):
    ...
    fullname = request.user.get_full_name()
    ...

Release

v0.1.0 2020/02/29

  • First release.

v0.2.0 2020/09/09

  • Add license in package.
  • Add replacing short name with full name support. It is controlled by USE_FULL_NAME_INSTEAD_OF_SHORT_NAME option in settings. USE_FULL_NAME_INSTEAD_OF_SHORT_NAME defaults to True, so that the name used in the default django's admin site topbar will be our full name.
  • Remove first_name, last_name parameter support for FULL_NAME_TEMPLATE, for user's customized User Model may not have first_name, last_name fields.
  • Fix documentations.

v0.2.1 2023/09/15

  • Doc update.

v0.2.2 2025/10/18

  • Doc update.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_fullname_localization-0.2.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_fullname_localization-0.2.2-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file django_fullname_localization-0.2.2.tar.gz.

File metadata

File hashes

Hashes for django_fullname_localization-0.2.2.tar.gz
Algorithm Hash digest
SHA256 2f0bd74536951dd9535a72dbecf25eb61abe3ebaf4fd14649d44f86f6a9ff52a
MD5 f79624cfc9751eedaca5fee09b3232fb
BLAKE2b-256 849cbb33d16600df59ddc8f5c0a03835b7ac96bc3d0fac57407bf7af01d631eb

See more details on using hashes here.

File details

Details for the file django_fullname_localization-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_fullname_localization-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ea09393355b1405de388a7378fdd76273eaccb32cbf6c8ec4fdb2c371c36f546
MD5 476cd1bf9fea65aeb1254a3a928fc0d7
BLAKE2b-256 8f42dbeb19e8fe9a9cfff8a580a39c025681b48ce556d1cccfe1e75668d165c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page