Django联系人申请表
django-contactform的Python项目详细描述
显示基本联系人表单。
演示
提供演示here
安装
来自PYPI
pip install django-contactform
来源:
python setup.py install
配置
设置.py
编辑settings.py文件并将geelweb.django.contactform添加到 INSTALLED_APPS
设置属性
contactform_recipients:邮件的电子邮件地址列表 发送。
CONTACTFORM_RECIPIENTS=['yourname@example.com','anotherperson@example.com']
contactform_subject_prefix:要添加到电子邮件主题的前缀
CONTACTFORM_SUBJECT_PREFIX='mail from contactform'
url.py
编辑url.py并添加以下行
url(r'^contact/$','geelweb.django.contactform.views.contact',name='contact'),
模板
创建contactForm/contact.html模板
<formaction="{% url 'contact' %}"method="post"> {% csrf_token %} {{ form.as_p }} <inputtype="submit"value="Submit"/></form>
然后是contactform/thanks.html模板
<h1>Thanks for your message</h1><div>Your message has been sent, we'll try to answer you as quickly as possible.</div>
django.core.mail
最后检查您配置的django.core.mail https://docs.djangoproject.com/en/dev/topics/email/
测试
运行单元测试
python tests/runtests.py