[Answered ]-How to validate fields with foreign keys in serializers context?

1👍

Solved it using this code:

def validate(self, data):
    if data['requesterid'].userroleid_id != 3:
        raise serializers.ValidationError("Sorry! You entered a user with no requester permissions.")
    return data

Leave a comment