[Fixed]-Django REST Framework – serializer.is_valid() lose data

1πŸ‘

βœ…

Can you try replacing

fields = ('url')

with

fields = ('url',)

The parenthesis don’t automatically make them tuples. You have to add a comma after the string to indicate to python that it should be a tuple.

From the Docs:

A special problem is the construction of tuples containing 0 or 1
items: the syntax has some extra quirks to accommodate these. Empty
tuples are constructed by an empty pair of parentheses; a tuple with
one item is constructed by following a value with a comma (it is not
sufficient to enclose a single value in parentheses). Ugly, but
effective.

πŸ‘€iankit

Leave a comment