'Check that the code is a valid country code.
We leave the data in its original format so that the Django model\'s
CountryField can convert it to the internal representation used
by the django-countries library.'

def to_internal_value(self, data):

    if (data and (data not in self.COUNTRY_CODES)):
        raise serializers.ValidationError(u'{code}    is    not    a    valid    country    code'.format(code=data))
    return data
