django可扩展的用户注册应用程序,基本支持电子邮件用户推荐

django-registration-redux-referrals的Python项目详细描述


这是django注册(redux)的一个分支,为电子邮件推荐提供基本支持。

安装

pip install django registration redux转介

或者只需下载zip,将其解压缩并将“registration”目录复制到pythonpath中

配置

配置指令与django registration redux类似。这是全部 文档:http://django-registration-redux.readthedocs.org

在安装和配置之后,您只需要编写视图来发送推荐电子邮件。

示例:

# Import the ReferCodes and Refer models.
# The ReferCodes model holds refer codes generated by users.
# The Refer model holds referred users and the referees. Both are instances of django.contrib.auth.models.User

from registration.models import ReferCodes, Refer

# The ReferForm is a simple form with only an email field. You can implement your own if you like.

from registration.forms import ReferForm

# gen_code is a utility for generating the 20-character refer code

from registration.utils import gen_code

from django.core.mail import send_mail
from django.conf import settings
from django.contrib.sites.shortcuts import get_current_site
from django.core.urlresolvers import reverse


def refer(request):
    form = ReferForm()
    if request.POST:
        code = gen_code()
        obj, new = ReferCodes.objects.get_or_create(code=code, user=request.user)
        if new:
            # Generation of the refer URL
            # registration_register is the name of the registration url
            # Please note the structure of the URL
            url = 'http://' + get_current_site(request) + reverse('registration_register') + code + '/'
            # The refer email message
            message = "Hello, \n Please register for the writing service here {0}".format(url)
            # Sending the refer email.
            send_mail('Subject here', message, settings.EMAIL_HOST_USER,
                      [request.POST['email']], fail_silently=False)

        ...

注册的引用用户现在将被保存到引用表中,您将能够查询他们和他们的 裁判。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何在wix中为TARGETDIR和SourceDir提供路径?   java在custom starter中访问spring应用程序名称   没有构建带有ActionBarSherlock的java Android项目   java按钮边框不显示   JavaSpring:从表单数据获取文件输入流   javascript通知侦听器服务   java在Junit测试时遇到异常   java从文件中读取特定值   JavaFX:在很短的时间内隐藏窗格   如何在Docker中使用用户定义的引用类来容器化Java应用程序?   java如何更改项目的编译SDKversion?   是否有任何java/spring方法可以使用HttpServletRequest存储当前登录用户的会话信息?   Java中的双大于号(>>)?   Java阵列2x2及其工作原理   java Spring引导ddl自动生成器   java如何利用大量数据传输优化服务器客户端应用程序?   java在使用Windows的FLAG_全屏时ICS和Jelly Bean之间的不同行为   java如何获取当前在回收器视图的线性布局中不可见的视图