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


Python CardForm.save方法代码示例

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


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

示例1: select_payment

# 需要导入模块: from payments.forms import CardForm [as 别名]
# 或者: from payments.forms.CardForm import save [as 别名]
def select_payment(request, auction_id):
    session_card = 'auction_%s_payment' % auction_id
    # session_shipping = 'auction_%s_shipping' % auction_id

    member = request.user.get_profile()
    auction = get_object_or_404(request.user.items_won.filter(order=None), id=auction_id)
    cards = request.user.card_set.filter(deleted=False)

    id = request.POST.get('card')
    # action = request.POST.get('action')
    card = None
    if 'select' in request.POST:
        card = get_object_or_404(Card, id=id, user=request.user, deleted=False)
        request.session[session_card] = card.id
        return HttpResponseRedirect(reverse('checkout_review', args=[auction.id]))

    if request.method == 'POST':
        form = CardForm(request.POST)
        if form.is_valid():
            # data = form.cleaned_data
            card = form.save(commit=False)
            card.use = request.user
            card.save()
            request.session[session_card] = card.id
            cards = request.user.card_set.filter(deleted=False)
            form = CardForm()
    else:
        form = CardForm()

    return {
        'auction':auction,
        'form':form,
        'cards':cards,
        'card':card
    }
开发者ID:SocialShoppingNetwork,项目名称:Competitive-Social-Shopping-Django,代码行数:37,代码来源:views.py

示例2: manage_payments

# 需要导入模块: from payments.forms import CardForm [as 别名]
# 或者: from payments.forms.CardForm import save [as 别名]
def manage_payments(request, redirect_url='profile_account'):
    objects = request.user.card_set.filter(deleted=False)
    form = CardForm(request.POST or None)
    if form.is_valid():
        instance = form.save(commit=False)
        instance.user = request.user
        instance.save()
        return HttpResponseRedirect(reverse('profile_account'))

    return {
        'form':form,
        'cards':objects,
    }
开发者ID:SocialShoppingNetwork,项目名称:Competitive-Social-Shopping-Django,代码行数:15,代码来源:views.py


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