嗨,伙计,我是 Django 的新手。什么可能导致这个例外?请帮帮我。
模型.py
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(sender, instance, created, **kwargs):
if created:
message = "New participant"
subject = "Updates"
from_email = 'bakotech.events@gmail.com'
recipient_list = ('sergey@avetisyan.com.ua')
send_mail(subject, message, from_email, recipient_list)
post_save.connect(send_marketing, sender=ParticipantModel)
表格.py
class ParticipantForm(forms.ModelForm):
class Meta(object):
model = ParticipantModel
视图.py
class CreateParticipant(CreateView):
form_class = ParticipantForm
template_name = 'registraition.html'
success_url = '/'
def form_valid(self, form):
VendorModel.objects.create(**form.cleaned_data)
return redirect(self.get_success_url())
这个错误是在我将信号建模后出现的。我不知道该怎么做才能在 django 学习中前进以及在哪里挖掘答案。在我改变观点之后
def form_invalid(self, form):
VendorModel.objects.create(**form.cleaned_data)
return redirect(self.get_success_url())
我发现了另一个错误而不是这个:
AssertionError at /reg
"to" argument must be a list or tuple
Request Method: POST
Request URL:
Django Version: 1.5
Exception Type: AssertionError
Exception Value:
"to" argument must be a list or tuple
Exception Location: /usr/local/lib/python2.7/dist-packages/django/core/mail/message.py in __init__, line 192
Python Executable: /usr/bin/python
Python Version: 2.7.4
Python Path:
['/home/ser/PycharmProjects/last/bakoevents',
'/home/ser/src/userena',
'/usr/local/lib/python2.7/dist-packages/w3lib-1.3-py2.7.egg',
'/usr/local/lib/python2.7/dist-packages',
'/home/ser/PycharmProjects/last/bakoevents',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages/PIL',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PILcompat',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client']
Server time: Вск, 8 Сен 2013 22:43:35 +0300