Commit 95e40fc5 authored by Tom van Bussel's avatar Tom van Bussel
Browse files

Use get for dict access in order serializer

parent 505813cb
......@@ -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)
Markdown is supported
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