在将PostgreSQL服务器信息保存在Django的setting.py文件中并正在运行服务器时,出现语法错误。以下是我保存在setting.py中的设置:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'webportal',
'USER': 'postgres',
'PASSWORD': 'password'
'HOST':'localhost',
'PORT' : '5432',
}
}
,错误是:-
\Django_Project\project2\WebPortal-Project>manage.py runserver
Traceback (most recent call last):
File "C:\Users\AJ!!\Dropbox\Django_Project\project2\WebPortal-Project\manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\AJ!!\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
utility.execute()
File "C:\Users\AJ!!\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 317, in execute
settings.INSTALLED_APPS
File "C:\Users\AJ!!\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\conf\__init__.py", line 56, in __getattr__
self._setup(name)
File "C:\Users\AJ!!\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\conf\__init__.py", line 43, in _setup
self._wrapped = Settings(settings_module)
File "C:\Users\AJ!!\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\conf\__init__.py", line 106, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Users\AJ!!\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 674, in exec_module
File "<frozen importlib._bootstrap_external>", line 781, in get_code
File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "C:\Users\AJ!!\Dropbox\Django_Project\project2\WebPortal-Project\WebPortal\settings.py", line 83
'HOST':'localhost',
^
SyntaxError: invalid syntax
请帮助我找出出现此语法错误的原因。
答案 0 :(得分:1)
在'PASSWORD': 'password'
行之后您缺少逗号。