为什么我收到 NameError: global name 'send_mail' is not defined
?
从我的models.py:
from django.template import Context, loader
from django.utils.translation import ugettext as _
from django.core.mail import send_mail
.......
class Payment(models.Model):
# send email for payment
# 1. render context to email template
email_template = loader.get_template('classifieds/email/payment.txt')
context = Context({'payment': self})
email_contents = email_template.render(context)
# 2. send email
send_mail(_('Your payment has been processed.'),
email_contents, settings.FROM_EMAIL,
[self.ad.user.email], fail_silently=False)
谢谢!
Traceback:
File "/home/.../webapps/django/lib/python2.7/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/home/.../webapps/django/lib/python2.7/django/views/decorators/csrf.py" in wrapped_view
77. return view_func(*args, **kwargs)
File "/home/.../webapps/django/myproject/classifieds/views/create.py" in checkout
122. send_mail(_('Your ad will be posted shortly.'),
Exception Type: NameError at /checkout/2
Exception Value: global name 'send_mail' is not defined