-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Closed
Labels
Milestone
Description
Just verifying this was an intended change from 2.4 -> 3.0 that now requires specifying a null value for resource creation when Model fields contains blank=True and null=True (without default=) since the ORM will handle it:
models.py
class Test(models.Model):
name = models.CharField(max_length=255)
description = models.TextField(blank=True, null=True)
class TestSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Test
fields = ('url', 'name', 'description')
class TestViewSet(viewsets.ModelViewSet):
queryset = Test.objects.all()
serializer_class = TestSerializer
(drf30)$ curl -H 'Accept: application/json; indent=4' -X POST -d "name=whatsup" http://127.0.0.1:8000/tests/
{
"description": [
"This field is required."
]
}
Thyrst, KeynesYouDigIt, sebitoelcheater and Mukhametvaleev