Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在Django中扩展设置文件?_Python_Django - Fatal编程技术网

Python 如何在Django中扩展设置文件?

Python 如何在Django中扩展设置文件?,python,django,Python,Django,我正在使用配置项目中的一些值。 根据Constance的说法,我应该在settings.py文件中添加所有配置。 但我需要在另一个文件中分离此配置。 我试图通过执行下面的代码来扩展设置文件,但没有成功 它不是从新文件中读取值 from .settings import * CONSTANCE_ADDITIONAL_FIELDS = { 'corres_format_select': ['django.forms.fields.ChoiceField', { 'widget': 'dj

我正在使用配置项目中的一些值。 根据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'),
} 

写入另一个文件并导入到设置文件中

您需要将manage.py,或者uwsgi.py文件指向该新文件,而不是settings.py。

否,因为我需要项目使用default settings.py,但我也需要它从另一个文件读取更多值。我不这么认为,因为我不想替换设置文件,我只想扩展itOk,这非常混乱。请澄清你的意图。是的!我在default settings.py中导入新文件