我正在尝试使用BradWhittington Django-Templated-Email。我安装了它,并在settings.py中添加了以下行。
from templated_email.backends.vanilla_django import TemplateBackend
TEMPLATED_EMAIL_BACKEND = TemplateBackend
当我尝试运行服务器时,出现导入错误。即使我使用
from templated_email import send_templated_mail
在models.py中的我再次得到导入错误。我是django的新手,我多次搜索答案。但没有运气。我错过了什么? ' Run' pycharm上的窗口显示以下内容:
"C:\Program Files\JetBrains\PyCharm 4.0.4\bin\runnerw.exe" "E:\***\***\***\env1\Scripts\python.exe" "C:\Program Files\JetBrains\PyCharm 4.0.4\helpers\pycharm\django_manage.py" syncdb "E:/***/***/***/***"
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 4.0.4\helpers\pycharm\django_manage.py", line 41, in <module>
run_module(manage_file, None, '__main__', True)
File "C:\Python34\Lib\runpy.py", line 182, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "C:\Python34\Lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Python34\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "E:/***/***/***/***\manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "E:\***\***\***\env1\lib\site-packages\django\core\management\__init__.py", line 385, in execute_from_command_line
utility.execute()
File "E:\***\***\***\env1\lib\site-packages\django\core\management\__init__.py", line 345, in execute
settings.INSTALLED_APPS
File "E:\***\***\***\env1\lib\site-packages\django\conf\__init__.py", line 46, in __getattr__
self._setup(name)
File "E:\***\***\***\env1\lib\site-packages\django\conf\__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "E:\***\***\***\env1\lib\site-packages\django\conf\__init__.py", line 94, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "E:\***\***\***\env1\lib\importlib\__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "E:/***/***/***/***\***\settings.py", line 17, in <module>
from templated_email.backends.vanilla_django import TemplateBackend
File "E:\***\***\***\env1\lib\site-packages\templated_email\__init__.py", line 23
except ImportError, e:
^
SyntaxError: invalid syntax
Process finished with exit code 1
我正在使用虚拟环境。请帮帮我。
答案 0 :(得分:0)
Django-Templated-Email不支持你正在使用的python 3。 您可以将项目迁移到python2,但最好找到Django-Templated-Email的现代替代方案。