How to change time input format in Django Admin?

41 Views Asked by At

The Django docs describe the use of TIME_INPUT_FORMATS, and say that the formats are described using the Python datetime module syntax.

But in Django Admin 4.2 none of the directives - I'm using %H, %M, %I, %p - are making any difference. Instead, only 24-hour time inputs are accepted, with and without leading zeros.

How do I gain control over the format, preferably without altering admin templates?

Here are the other relevant settings:

settings.py

LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'America/Denver'
USE_TZ = True
USE_I18N = False 

There's the input_formats argument for DateTimeField, but that includes date formats, and I need just the time formats separately (for a Django Admin detail view of an object that has a datetime field).

There's also another question about display of times that looks interesting, but I'm concerned now with time input.

0

There are 0 best solutions below