Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django联系表确认电子邮件_Python_Django_Django Forms_Django Views - Fatal编程技术网

Python Django联系表确认电子邮件

Python Django联系表确认电子邮件,python,django,django-forms,django-views,Python,Django,Django Forms,Django Views,我对django和构建我的第一个应用程序相对来说比较陌生 我试着在网站上搜索,但我一生都找不到所需的相关信息 我希望有一个确认电子邮件发送到输入的电子邮件地址的联系形式。我见过向选定地址或用户发送邮件的例子,但我似乎不知道如何向表单中输入的电子邮件发送邮件 非常感谢您的帮助 models.py: from django.db import models class Quote(models.Model): name = models.CharField(max_length=200,

我对django和构建我的第一个应用程序相对来说比较陌生

我试着在网站上搜索,但我一生都找不到所需的相关信息

我希望有一个确认电子邮件发送到输入的电子邮件地址的联系形式。我见过向选定地址或用户发送邮件的例子,但我似乎不知道如何向表单中输入的电子邮件发送邮件

非常感谢您的帮助

models.py

from django.db import models

class Quote(models.Model):
    name = models.CharField(max_length=200, blank=False, null=False, verbose_name="your name")
    email = models.EmailField(max_length=255, blank=False, null=False)

    created_at = models.DateTimeField(auto_now=True)

    def __unicode__(self):
        return self.name
class QuoteForm(forms.ModelForm):
    class Meta:
        model = Quote
class QuoteView(CreateView):
    model = Quote
    form_class = QuoteForm
    template_name = "quote/quote.html"
    success_url = "/quote/success/"

    def form_valid(self, form):
        super(QuoteView,self).form_valid(form)
        return HttpResponseRedirect(self.get_success_url())

class QuoteSuccessView(TemplateView):
    template_name = "quote/quote-complete.html"
forms.py

from django.db import models

class Quote(models.Model):
    name = models.CharField(max_length=200, blank=False, null=False, verbose_name="your name")
    email = models.EmailField(max_length=255, blank=False, null=False)

    created_at = models.DateTimeField(auto_now=True)

    def __unicode__(self):
        return self.name
class QuoteForm(forms.ModelForm):
    class Meta:
        model = Quote
class QuoteView(CreateView):
    model = Quote
    form_class = QuoteForm
    template_name = "quote/quote.html"
    success_url = "/quote/success/"

    def form_valid(self, form):
        super(QuoteView,self).form_valid(form)
        return HttpResponseRedirect(self.get_success_url())

class QuoteSuccessView(TemplateView):
    template_name = "quote/quote-complete.html"
views.py

from django.db import models

class Quote(models.Model):
    name = models.CharField(max_length=200, blank=False, null=False, verbose_name="your name")
    email = models.EmailField(max_length=255, blank=False, null=False)

    created_at = models.DateTimeField(auto_now=True)

    def __unicode__(self):
        return self.name
class QuoteForm(forms.ModelForm):
    class Meta:
        model = Quote
class QuoteView(CreateView):
    model = Quote
    form_class = QuoteForm
    template_name = "quote/quote.html"
    success_url = "/quote/success/"

    def form_valid(self, form):
        super(QuoteView,self).form_valid(form)
        return HttpResponseRedirect(self.get_success_url())

class QuoteSuccessView(TemplateView):
    template_name = "quote/quote-complete.html"

您可以通过
cleaned_data
属性访问已验证的表单数据(强制到相应类型的字段),如表单文档中所示


非常感谢你!工作得很好。