5👍
If you don’t want to update is_searchable you have to define it as read_only field in your serializer class.
Eg:
class YourSerializer(serializers.ModelSerializer):
is_searchable = serializers.BooleanField(read_only=True)
otherwise, pass the correct value true/false
0👍
I had a similar issue and I found it has to do with my curl command. You must add -H "Content-Type: application/json"
.
e.g.
curl -X PUT -H "Content-Type: application/json" -d '{"is_searchable": true}' http://<your-instance>/<your-api>/
- How do I set HttpOnly cookie in Django?
- Django blocktrans and i18n in templates
- Django filter queryset if a field exists
-2👍
You may use initial
class YourSerializer(serializers.ModelSerializer):
is_searchable = serializers.BooleanField(initial=True)
Source:stackexchange.com