6👍
✅
In your serializer class add a method to validate UnitOfMeasureName
like following:
def validate_unitofmasurename(self, value):
UnitOfMeasureName = ["Each", "Grams", "Ounces", "Pounds", "Kilograms", "Metric Tons"]
if value in UnitOfMeasureName:
return True
else:
return ValidationError('Invalid masure name')
Source:stackexchange.com