Use of TIME_INPUT_FORMATS in TimeField

Skip to first unread message

Arthur Pemberton

Mar 5, 2024, 2:43:22 AMMar 5
The documentation ( says that " the default input formats are taken from the active locale format TIME_INPUT_FORMATS key, or from TIME_INPUT_FORMATS if localization is disabled". However, neither my reading of the code, or my actual experience shows settings.TIME_INPUT_FORMATS ever being used, even with "USE_I18N = False"

TimeField gets the formats from `input_formats = formats.get_format_lazy("TIME_INPUT_FORMATS")` which is a lazy version of `formats.get_format` -- the documentation of which says "If use_l10n is provided and is not None, it forces the value to be localized (or not), otherwise it's always localized."

so even with "USE_I18N = False" settings.TIME_INPUT_FORMATS seems to be ignored.

How does one use settings.TIME_INPUT_FORMATS ?

Arthur Pemberton

David Sanders

Mar 5, 2024, 3:00:43 AMMar 5
Define TIME_INPUT_FORMATS in your local setup as per:

You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Arthur Pemberton

Mar 5, 2024, 3:48:58 AMMar 5
Thanks, I'll look into that. But does that mean that settings.TIME_INPUT_FORMATS no longer has any use? I don't see any logic flows that lead to it being used.

Adam Johnson

Mar 5, 2024, 3:41:10 PMMar 5
to Arthur Pemberton,
USE_I18N does not disable localization, but internationalization. USE_L10N was the setting to enable/disable localization, but it was deprecated in Django 4.0: . It was removed completely in Django 5.0, in this commit: .

So I think the phrase “if localization is disabled” is at least a little bit wrong. But I don’t think the setting is ignored, as there are tests confirming that it works: . The line that reads the setting should be this one: .

If you can provide a failing minimal project, that would be useful to keep debugging. I have some minimal django project templates at .

Arthur Pemberton

May 18, 2024, 4:14:37 PMMay 18
to Adam Johnson,
I haven't yet checked the tests thoroughly enough to determine why things didn't work for me in practice. I do know they didn't work. And I do see that the tests pass. But I suspect that the tests may not be fully mimicking the read-world use case in this scenario.

I'll return here once I have some evidence either way,

Arthur Pemberton

Natraj Kavander

May 18, 2024, 9:06:33 PMMay 18
to, Adam Johnson
Reply all
Reply to author
0 new messages