i am tring to add boolean field true through postman but it is giving an 
error,and i am unable to figure out the problem
models.py
class Tutorial(models.Model):
title=models.CharField(max_length=50,blank=False,default='')
description=models.CharField(max_length=200,blank=False,default='')
published=models.BooleanField(default=False)

def __str__(self):
return str(self.title)

serializer
class TutorialSerializer(serializers.ModelSerializer):

class Meta:
model=Tutorial

fields=('id',
'description',
'title')
def create(self,validated_data):
title = validated_data ['title']
description=validated_data['description']
published=validated_data['published']
instance = Tutorial.objects.create(**validated_data)
# for i in title:
# instance.title.add(i)

return instance
VIEWS.PY
class TutorialViewSet(viewsets.ModelViewSet):
serializer_class = TutorialSerializer
#queryset = Tutorial.objects.all()
def create(self, request):
try:
serializer_class = TutorialSerializer(data=request.data)
serializer_class.is_valid(raise_exception=True)
instance = self.perform_update(serializer_class)

read_serializer = TutorialSerializer(instance)
return Response(read_serializer.data)
except Exception as error:
#traceback.print_exc()
return Response({"message": str(error), "success": False}, 
status=status.HTTP_200_OK)

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-rest-framework/a740bebb-93c6-475b-94a4-8c1d926ae43an%40googlegroups.com.

Reply via email to