Do not use imports in custom formats file

Using imports here apparently does not work as all the formats have to get
loaded before the new ones can be added, which means that the newly added
formats do not get recognized until the application restarts.

Fixes #90, again.
This commit is contained in:
Christopher C. Wells 2020-01-21 07:22:30 -08:00
parent d9280d4887
commit e1d17759de
1 changed files with 23 additions and 8 deletions

View File

@ -1,9 +1,24 @@
# -*- coding: utf-8 -*-
from django.utils.formats import get_format
# Adds support for datetime formats used by frontend.
formats = get_format('DATETIME_INPUT_FORMATS', lang='en')
# This files adds two new date input formats to support Baby Buddy's frontend
# library formats:
# - %m/%d/%Y %I:%M:%S %p
# - %m/%d/%Y %I:%M %p
#
# The remaining formats come from the base Django formats.
#
# See django.cong.locale.en.
DATETIME_INPUT_FORMATS = [
'%m/%d/%Y %I:%M:%S %p',
'%m/%d/%Y %I:%M %p'
] + formats
'%m/%d/%Y %I:%M:%S %p', # '10/25/2006 2:30:59 PM' (new)
'%m/%d/%Y %I:%M %p', # '10/25/2006 2:30 PM' (new)
'%Y-%m-%d %H:%M:%S', # '2006-10-25 14:30:59'
'%Y-%m-%d %H:%M:%S.%f', # '2006-10-25 14:30:59.000200'
'%Y-%m-%d %H:%M', # '2006-10-25 14:30'
'%Y-%m-%d', # '2006-10-25'
'%m/%d/%Y %H:%M:%S', # '10/25/2006 14:30:59'
'%m/%d/%Y %H:%M:%S.%f', # '10/25/2006 14:30:59.000200'
'%m/%d/%Y %H:%M', # '10/25/2006 14:30'
'%m/%d/%Y', # '10/25/2006'
'%m/%d/%y %H:%M:%S', # '10/25/06 14:30:59'
'%m/%d/%y %H:%M:%S.%f', # '10/25/06 14:30:59.000200'
'%m/%d/%y %H:%M', # '10/25/06 14:30'
'%m/%d/%y', # '10/25/06'
]