I want to iterate colors in Django, it should print first red then green
# data from frontend react
data = request.data
print(data)
<QueryDict: {'colors': ['red', 'green']}>
result should be like this :
red
green
I want to iterate colors in Django, it should print first red then green
# data from frontend react
data = request.data
print(data)
<QueryDict: {'colors': ['red', 'green']}>
result should be like this :
red
green
You can use the .getlist(…) method [Django-doc] to access the list of values, so:
>>> print(data.getlist('colors'))
['red', 'green']