本文整理汇总了Python中models.Profile.coord_from方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.coord_from方法的具体用法?Python Profile.coord_from怎么用?Python Profile.coord_from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Profile
的用法示例。
在下文中一共展示了Profile.coord_from方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sign_up
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import coord_from [as 别名]
def sign_up(request):
page = get_object_or_404(Page, slug='sign-up')
state = None
form = SignUpForm(request.POST or None)
if form.is_valid():
if (form.cleaned_data['password'] == form.cleaned_data['password_check']):
email = form.cleaned_data['email']
username = form.cleaned_data['username']
try:
user_name = User.objects.get(username=username) or None
if user_name is not None:
state = 'User with that name already exists.'
return render_to_response('account/signup.html', {'page': page, 'state': state, 'form': form}, context_instance=RequestContext(request))
except:
pass
try:
user_email = User.objects.get(email=email) or None
if user_email is not None:
state = 'User with that email already exists.'
return render_to_response('account/signup.html', {'page': page, 'state': state, 'form': form}, context_instance=RequestContext(request))
except:
pass
user = User.objects.create_user(form.cleaned_data['username'], form.cleaned_data['email'], form.cleaned_data['password'])
user.is_active = True
user.save()
profile = Profile(user=user)
profile.email = form.cleaned_data['email']
profile.coord_from = form.cleaned_data['coord_from']
profile.coord_to = form.cleaned_data['coord_to']
profile.save()
user = authenticate(username=form.cleaned_data['username'], password=form.cleaned_data['password'])
if user is not None:
login(request, user)
if request.POST.get('to_cart'):
return redirect('/cart/')
return redirect('/')
else:
state = "Password's don't match."
return render_to_response('account/signup.html', {'page': page, 'state': state, 'form': form}, context_instance=RequestContext(request))