Skip to content

Commit

Permalink
Since shipping_address is not required in the serializer it is very v…
Browse files Browse the repository at this point in the history
…ery very

very very very very very unwise to assume it is present in validated_data
  • Loading branch information
specialunderwear authored and Martijn Jacobs committed Dec 15, 2017
1 parent 1b5342d commit 8c75c9d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions oscarapi/serializers/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,11 @@ def create(self, validated_data):
order_number = self.generate_order_number(basket)
request = self.context['request']

shipping_address = ShippingAddress(
**validated_data['shipping_address'])
if 'shipping_address' in validated_data:
shipping_address = ShippingAddress(
**validated_data['shipping_address'])
else:
shipping_address = None

if 'billing_address' in validated_data:
billing_address = BillingAddress(
Expand Down

0 comments on commit 8c75c9d

Please sign in to comment.