本文整理汇总了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})
示例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})