【发布时间】:2020-02-29 18:29:46
【问题描述】:
我正在使用Constance - Dynamic Django settings 在我的项目中配置一些值。 根据 Constance,我应该在 settings.py 文件中添加所有配置。 但我需要将此配置分隔在另一个文件中。 我尝试通过执行下面的代码来扩展设置文件,但它不起作用 它没有从那个新文件中读取值。
from .settings import *
CONSTANCE_ADDITIONAL_FIELDS = {
'corres_format_select': ['django.forms.fields.ChoiceField', {
'widget': 'django.forms.Select',
'choices': (("xx - xx", "xx - xx"), ("xx/xx", "xx/xx"), ("xx : xx", "xx : xx"))}],
'date_format_select': ['django.forms.fields.ChoiceField', {
'widget': 'django.forms.Select',
'choices': (("dd/mm/yyyy", "dd/mm/yyyy"), ("mm/dd/yyyy", "mm/dd/yyyy"), ("dd-mm-yyyy", "dd-mm-yyyy"))}],
}
CONSTANCE_CONFIG = {
'Correspondence_format': ("xx - xx", 'Choose the correspondce format', 'corres_format_select'),
'Date_format': ("dd/mm/yyyy", 'Choose the date format', 'date_format_select'),
}
【问题讨论】:
-
不,因为我需要项目使用默认 settings.py 但我也需要它从另一个文件中读取更多值。