本文整理汇总了Python中orders.models.Order.billing_address方法的典型用法代码示例。如果您正苦于以下问题:Python Order.billing_address方法的具体用法?Python Order.billing_address怎么用?Python Order.billing_address使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类orders.models.Order
的用法示例。
在下文中一共展示了Order.billing_address方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from orders.models import Order [as 别名]
# 或者: from orders.models.Order import billing_address [as 别名]
def get(self, request, *args, **kwargs ):
get_data = super(CheckoutView, self).get(request, *args, **kwargs)
cart = self.get_object()
user_checkout_id = request.session.get("user_checkout_id")
if user_checkout_id != None:
user_checkout = UserCheckout.objects.get(id=user_checkout_id)
billing_address_id = request.session.get("billing_address_id")
shipping_address_id = request.session.get("shipping_address_id")
if billing_address_id == None or shipping_address_id == None:
return redirect('order_address')
else:
billing_address = UserAddress.objects.get(id=billing_address_id)
shipping_address = UserAddress.objects.get(id=shipping_address_id)
try:
new_order_id = request.session['order_id']
new_order = Order.objects.get(id=new_order_id)
except:
new_order = Order()
request.session["order_id"] = new_order.id
# new_order.cart = cart
new_order.user = user_checkout
new_order.billing_address = billing_address
new_order.shipping_address = shipping_address
new_order.save()
return get_data