Commit 9035c25c authored by Wietse Kuipers's avatar Wietse Kuipers
Browse files

Merge branch 'fix/pizzas-api-orders-dict-get' into 'master'

Use get for dict access in order serializer

See merge request thalia/concrexit!629
parents 505813cb 95e40fc5
......@@ -33,11 +33,11 @@ class AdminOrderSerializer(serializers.ModelSerializer):
fields = ('pk', 'paid', 'product', 'name', 'member')
def validate(self, attrs):
if attrs['member'] and attrs['name']:
if attrs.get('member') and attrs.get('name'):
raise ValidationError({
'member': _('Either specify a member or a name'),
'name': _('Either specify a member or a name'),
if not (attrs['member'] or attrs['name']):
if not (attrs.get('member') or attrs.get('name')):
attrs['member'] = self.context['request'].member
return super().validate(attrs)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment