I’m trying to implement a simple validator for my POST parameters
My input looks like this:
{
"gage_id": "01010000",
"forcing_source":"my_source",
"forcing_path":"my_path"
}
I have the following Serializer:
class SaveTab1Serializer(Serializer):
gage_id = CharField(min_length=1, required=True),
forcing_source = CharField(min_length=1, required=True),
forcing_path = CharField(min_length=1, required=True),
And I use it like this:
@api_view(['POST'])
def save_tab1(request):
body = json.loads(request.body)
ser = SaveTab1Serializer(data=body)
print('serializer', ser.is_valid())
print('errors', ser.errors)
But now matter what I do with the data, it only shows as valid with no errors. Is there more code that I need to add to the serializer to do the validation?