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


Python Profile.coord_from方法代码示例

本文整理汇总了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))
开发者ID:xal,项目名称:Poputchik_3,代码行数:41,代码来源:views.py


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