I am trying to allow the input of more flexible dates in my application and would like to use the default Django settings. In the documentation, I can define DATE_INPUT_FORMATSin settings.py, but I would like to keep the defaults and add a few others.
I tried to expand it, as if it already existed, which failed miserably:
DATE_INPUT_FORMATS += ['%m-%d-%y',]
Productivity: NameError: name 'DATE_INPUT_FORMATS' is not defined
I also tried importing the default settings from django.conf, but it is circular because it is trying to enable mine settings.py, which I am loading.
from django.conf import settings as default_settings
DATE_INPUT_FORMATS = default_settings.DATE_INPUT_FORMATS
DATE_INPUT_FORMATS += ['%m-%d-%y',]
Productivity:
Error: Can't find the file 'settings.py' in the directory containing './manage.py'. It appears you've customized things.
You'll have to run django-admin.py, passing it your settings module.
(If the file settings.py does indeed exist, it causing an ImportError somehow.)
What is the correct way to extend the default value in Django settings.py?
source
share