installing django-templated-email

2019-05-31 16:24发布

问题:

I'm learning how to develop in Django, so there are a lot of things I've still have to learn, so, if I have any concept error, please notify me.

My problem is that I'm trying to install django-templated-email package so I can send emails from my app using mailchimp, I downloaded https://github.com/bradwhittington/django-templated-email and followed the instructions (used the pip instruction from project root folder), but, when I add:

from templated_email.backends.vanilla_django import TemplateBackend
TEMPLATED_EMAIL_BACKEND = TemplateBackend

to my settings.py, I get this error when trying to run local server:

ImportError: Could not import settings 'proyect.settings' (Is it on sys.path?): No module named templated_email.backends.vanilla_django

I've read it works out of the box, so I just can delete these rows and still get the package to work (or at least that's what I understand). My real problem comes when adding this in my views.py so I can use the package:

from templated_email import send_templated_mail

I allways get this error:

ImportError at /awards/get/reward/
No module named templated_email
Request Method: POST
Request URL:    http://127.0.0.1:8000/awards/get/reward/
Django Version: 1.4
Exception Type: ImportError
Exception Value:    
No module named templated_email
Exception Location: /Users/xxxxx/xxxx/proyect/proyect/quizzer/views.py in awards_get, line 1316
Python Executable:  /usr/bin/python
Python Version: 2.7.1
Python Path:    
['/Users/xxxxx/xxxx/proyect/proyect',
 '/Library/Python/2.7/site-packages/pip-1.0-py2.7.egg',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
'/Library/Python/2.7/site-packages',
'/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']
Server time:    sáb, 12 Ene 2013 10:48:28 +0100

It's in line 1316 where I add the import line

Hope you can help me solve my problem so I can start sending emails and newsletters!

回答1:

You added /Users/xxxxx/xxxx/proyect/proyect in your python path but not added /Users/xxxxx/xxxx/proyect