module documentation

Undocumented

Function date_format Format a datetime.date or datetime.datetime object using a localizable format.
Function get_format For a specific format type, return the format for the current language (locale). Default to the format in the settings. format_type is the name of the format, e.g. 'DATE_FORMAT'.
Function get_format_modules Return a list of the format modules found.
Function iter_format_modules Find format modules.
Function localize Check if value is a localizable type (date, number...) and return it formatted as a string using current locale format.
Function localize_input Check if an input value is a localizable type and return it formatted with the appropriate formatting string of the current locale.
Function number_format Format a numeric value using localization settings.
Function reset_format_cache Clear any cached formats.
Function sanitize_separators Sanitize a value according to the current decimal and thousand separator setting. Used with form field input.
Function sanitize_strftime_format Ensure that certain specifiers are correctly padded with leading zeros.
Function time_format Format a datetime.time object using a localizable format.
Constant FORMAT_SETTINGS Undocumented
Constant ISO_INPUT_FORMATS Undocumented
Variable get_format_lazy Undocumented
Variable _format_cache Undocumented
Variable _format_modules_cache Undocumented
def date_format(value, format=None, use_l10n=None): (source)

Format a datetime.date or datetime.datetime object using a localizable format. If use_l10n is provided and is not None, that will force the value to be localized (or not), overriding the value of settings.USE_L10N.

def get_format(format_type, lang=None, use_l10n=None): (source)

For a specific format type, return the format for the current language (locale). Default to the format in the settings. format_type is the name of the format, e.g. 'DATE_FORMAT'. If use_l10n is provided and is not None, it forces the value to be localized (or not), overriding the value of settings.USE_L10N.

def get_format_modules(lang=None): (source)

Return a list of the format modules found.

def iter_format_modules(lang, format_module_path=None): (source)

Find format modules.

def localize(value, use_l10n=None): (source)

Check if value is a localizable type (date, number...) and return it formatted as a string using current locale format. If use_l10n is provided and is not None, it forces the value to be localized (or not), overriding the value of settings.USE_L10N.

def localize_input(value, default=None): (source)

Check if an input value is a localizable type and return it formatted with the appropriate formatting string of the current locale.

def number_format(value, decimal_pos=None, use_l10n=None, force_grouping=False): (source)

Format a numeric value using localization settings. If use_l10n is provided and is not None, it forces the value to be localized (or not), overriding the value of settings.USE_L10N.

def reset_format_cache(): (source)

Clear any cached formats. This method is provided primarily for testing purposes, so that the effects of cached formats can be removed.

def sanitize_separators(value): (source)

Sanitize a value according to the current decimal and thousand separator setting. Used with form field input.

@functools.lru_cache
def sanitize_strftime_format(fmt): (source)

Ensure that certain specifiers are correctly padded with leading zeros. For years < 1000 specifiers %C, %F, %G, and %Y don't work as expected for strftime provided by glibc on Linux as they don't pad the year or century with leading zeros. Support for specifying the padding explicitly is available, however, which can be used to fix this issue. FreeBSD, macOS, and Windows do not support explicitly specifying the padding, but return four digit years (with leading zeros) as expected. This function checks whether the %Y produces a correctly padded string and, if not, makes the following substitutions: - %C → %02C - %F → %010F - %G → %04G - %Y → %04Y See https://bugs.python.org/issue13305 for more details.

def time_format(value, format=None, use_l10n=None): (source)

Format a datetime.time object using a localizable format. If use_l10n is provided and is not None, it forces the value to be localized (or not), overriding the value of settings.USE_L10N.

FORMAT_SETTINGS = (source)

Undocumented

Value
frozenset(['DECIMAL_SEPARATOR',
           'THOUSAND_SEPARATOR',
           'NUMBER_GROUPING',
           'FIRST_DAY_OF_WEEK',
           'MONTH_DAY_FORMAT',
           'TIME_FORMAT',
           'DATE_FORMAT',
...
ISO_INPUT_FORMATS: dict = (source)

Undocumented

Value
{'DATE_INPUT_FORMATS': ['%Y-%m-%d'],
 'TIME_INPUT_FORMATS': ['%H:%M:%S', '%H:%M:%S.%f', '%H:%M'],
 'DATETIME_INPUT_FORMATS': ['%Y-%m-%d %H:%M:%S',
                            '%Y-%m-%d %H:%M:%S.%f',
                            '%Y-%m-%d %H:%M',
                            '%Y-%m-%d']}
get_format_lazy = (source)

Undocumented

_format_cache: dict = (source)

Undocumented

_format_modules_cache: dict = (source)

Undocumented