再会。带有信号的模型必须发送到电子邮件实例,但我有回溯,我放置在代码块之后
class ParticipantModel(models.Model):
TYPE_USER = (
('O', 'Онлайн трансляция'),
('P', 'Персональное присутствие'),
)
name = models.CharField( max_length=256, verbose_name='Имя')
surname = models.CharField(max_length=50, verbose_name='Фамилия')
position = models.CharField(max_length=50, verbose_name='Должность')
company = models.CharField(max_length=50, verbose_name='Название компании')
city = models.CharField(max_length=50, verbose_name='Город')
email = models.EmailField(verbose_name='Электро почта')
phone = models.CharField(max_length="50", verbose_name="Телефон")
phonem = models.CharField(max_length="50", verbose_name="Мобильный телефон")
www = models.URLField(verbose_name="Сайт")
tuser = models.CharField(max_length='250', choices=TYPE_USER, verbose_name="Форма вашего участия")
class Meta:
verbose_name = ('Участник')
verbose_name_plural = ('Участники')
def send_marketing(self, sender, instance, created, **kwargs):
if created:
message = instance
subject = "McAfee day"
from_email = 'bakotech.events@gmail.com'
recipient_list = ('sergey@avetisyan.com.ua', 'marketing@bakotech.com')
send_mail(subject, message, from_email, recipient_list)
post_save.connect(send_marketing, sender=ParticipantModel)
追溯:
/reg 'ParticipantModel' 对象的 AttributeError 没有属性 'encode' 请求方法:POST 请求 URL:
Django 版本:1.5.2 异常类型:AttributeError 异常值:
'ParticipantModel' 对象没有属性 'encode' 异常位置:/usr/ lib/python2.7/email/encoders.py in encode_7or8bit,第 73 行 Python 可执行文件:/usr/bin/uwsgi-core Python 版本:2.7.3 Python 路径:
['.', '', '/home/sergey/djprojects/venvs/bakoevents/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg', '/home/sergey/djprojects /venvs/bakoevents/local/lib/python2.7/site-packages/distribute-0.7.3-py2.7.egg', '/home/sergey/djprojects/venvs/bakoevents/local/lib/python2.7/站点包/setuptools-1.1-py2.7.egg', '/home/sergey/djprojects/venvs/bakoevents/lib/python2.7/site-packages/pip-1.1-py2.7.egg', '/ home/sergey/djprojects/venvs/bakoevents/lib/python2.7/site-packages/distribute-0.7.3-py2.7.egg', '/home/sergey/djprojects/venvs/bakoevents/lib/python2.7 /site-packages/setuptools-1.1-py2.7.egg','/home/sergey/djprojects/venvs/bakoevents/lib/python2.7','/home/sergey/djprojects/venvs/bakoevents/lib/python2 .7/plat-linux2', '/home/sergey/djprojects/venvs/bakoevents/lib/python2.7/lib-tk','/home/sergey/djprojects/venvs/bakoevents/lib/python2.7/lib-old','/home/sergey /djprojects/venvs/bakoevents/lib/python2.7/lib-dynload','/usr/lib/python2.7','/usr/lib/python2.7/plat-linux2','/usr/lib/ python2.7/lib-tk','/home/sergey/djprojects/venvs/bakoevents/local/lib/python2.7/site-packages','/home/sergey/djprojects/venvs/bakoevents/local/lib/ python2.7/site-packages/PIL', '/home/sergey/djprojects/venvs/bakoevents/lib/python2.7/site-packages', '/home/sergey/djprojects/venvs/bakoevents/lib/python2. 7/site-packages/PIL'] 服务器时间:Срд, 11 Сен 2013 19:49:00 +0300/home/sergey/djprojects/venvs/bakoevents/lib/python2.7/lib-dynload','/usr/lib/python2.7','/usr/lib/python2.7/plat-linux2','/ usr/lib/python2.7/lib-tk', '/home/sergey/djprojects/venvs/bakoevents/local/lib/python2.7/site-packages', '/home/sergey/djprojects/venvs/bakoevents/ local/lib/python2.7/site-packages/PIL', '/home/sergey/djprojects/venvs/bakoevents/lib/python2.7/site-packages', '/home/sergey/djprojects/venvs/bakoevents/ lib/python2.7/site-packages/PIL'] 服务器时间:Срд, 11 Сен 2013 19:49:00 +0300/home/sergey/djprojects/venvs/bakoevents/lib/python2.7/lib-dynload','/usr/lib/python2.7','/usr/lib/python2.7/plat-linux2','/ usr/lib/python2.7/lib-tk', '/home/sergey/djprojects/venvs/bakoevents/local/lib/python2.7/site-packages', '/home/sergey/djprojects/venvs/bakoevents/ local/lib/python2.7/site-packages/PIL', '/home/sergey/djprojects/venvs/bakoevents/lib/python2.7/site-packages', '/home/sergey/djprojects/venvs/bakoevents/ lib/python2.7/site-packages/PIL'] 服务器时间:Срд, 11 Сен 2013 19:49:00 +0300/home/sergey/djprojects/venvs/bakoevents/local/lib/python2.7/site-packages/PIL','/home/sergey/djprojects/venvs/bakoevents/lib/python2.7/site-packages',' /home/sergey/djprojects/venvs/bakoevents/lib/python2.7/site-packages/PIL'] 服务器时间:Срд,11 Сен 2013 19:49:00 +0300/home/sergey/djprojects/venvs/bakoevents/local/lib/python2.7/site-packages/PIL','/home/sergey/djprojects/venvs/bakoevents/lib/python2.7/site-packages',' /home/sergey/djprojects/venvs/bakoevents/lib/python2.7/site-packages/PIL'] 服务器时间:Срд,11 Сен 2013 19:49:00 +0300