当前位置: 首页>>代码示例>>Python>>正文


Python Player.image_url方法代码示例

本文整理汇总了Python中models.Player.image_url方法的典型用法代码示例。如果您正苦于以下问题:Python Player.image_url方法的具体用法?Python Player.image_url怎么用?Python Player.image_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Player的用法示例。


在下文中一共展示了Player.image_url方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: new_register

# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import image_url [as 别名]
def new_register(request):
    """ This is for a new user who wishes to register independent of twitter and facebook;
        we use gravatar for these users.
    """
    if request.method == 'POST':
        form = NewPlayerForm(request.POST)
        if form.is_valid():
            first_name = form.cleaned_data['first_name']
            last_name = form.cleaned_data['last_name']
            username = form.cleaned_data['username']
            email = form.cleaned_data['email']
            phone_number = form.cleaned_data['phone_number']
            sports = form.cleaned_data['sports']
            gender = form.cleaned_data['gender']
            password1 = form.cleaned_data['password1']
            #password2 = form.cleaned_data['password2'] # unused

            user = User.objects.create_user(username=username, email=email, password=password1)
            user.first_name = first_name
            user.last_name = last_name
            user.save()
            player = Player()
            player.gender = gender
            player.user = user
            player.phone_number = phone_number
            player.image_url = get_gravatar(player.user.email)
            player.save()
            player.sports = sports
            user = authenticate(username=player.user, password=password1)
            login(request, user)
            EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

            from django.core.mail import EmailMessage
            from django.template.loader import render_to_string
            from django.utils.html import strip_tags
            subject, from_email, to = 'Welcome', '[email protected]', user.email
            html_content = render_to_string('email_signup.html', {'user': user.first_name})
            text_content = strip_tags(html_content)
            msg = EmailMessage(subject, text_content, to=[to])
            msg.send()
            # task here to email user
            SignUpTask.delay(user)
            return HttpResponseRedirect('/')
    else:
        if 'email' in request.GET:
            form = NewPlayerForm(initial={'email': request.GET['email']})
        else:
            form = NewPlayerForm()
    return render(request, 'new_register.html', {'form': form})
开发者ID:nsnitesh7,项目名称:courtside,代码行数:51,代码来源:views.py

示例2: new_register

# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import image_url [as 别名]
def new_register(request):
    """ This is for a new user who wishes to register independent of twitter and facebook;
        we use gravatar for these users.
    """
    if request.method == 'POST':
        form = NewPlayerForm(request.POST)
        if form.is_valid():
            first_name = form.cleaned_data['first_name']
            last_name = form.cleaned_data['last_name']
            username = form.cleaned_data['username']
            email = form.cleaned_data['email']
            phone_number = form.cleaned_data['phone_number']
            sports = form.cleaned_data['sports']
            gender = form.cleaned_data['gender']
            password1 = form.cleaned_data['password1']
            #password2 = form.cleaned_data['password2'] # unused

            user = User.objects.create_user(username=username, email=email, password=password1)
            user.first_name = first_name
            user.last_name = last_name
            user.save()
            player = Player()
            player.gender = gender
            player.user = user
            player.phone_number = phone_number
            player.image_url = get_gravatar(player.user.email)
            player.save()
            player.sports = sports
            user = authenticate(username=player.user, password=password1)
            login(request, user)
            # task here to email user
            SignUpTask.delay(user)
            return HttpResponseRedirect('/')
    else:
        if 'email' in request.GET:
            form = NewPlayerForm(initial={'email': request.GET['email']})
        else:
            form = NewPlayerForm()
    return render(request, 'new_register.html', {'form': form})
开发者ID:DjangoBD,项目名称:courtside,代码行数:41,代码来源:views.py


注:本文中的models.Player.image_url方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。