本文整理匯總了Python中orders.models.Order.shipping_address方法的典型用法代碼示例。如果您正苦於以下問題:Python Order.shipping_address方法的具體用法?Python Order.shipping_address怎麽用?Python Order.shipping_address使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類orders.models.Order
的用法示例。
在下文中一共展示了Order.shipping_address方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get
# 需要導入模塊: from orders.models import Order [as 別名]
# 或者: from orders.models.Order import shipping_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