Set null value for floatfield

257 views
Skip to first unread message

Rakhee Menon

unread,
Jul 1, 2018, 8:09:11 AM7/1/18
to Django users
Hi,

Please could anyone tell how to set null value for FloatField and when I try with null=True and blank=true I get this error

AssertionError: Expected a `Response`, `HttpResponse` or `HttpStreamingResponse` to be returned from the view, but received a `<class 'NoneType'>`

Regards,
Rakhee

Jason

unread,
Jul 1, 2018, 8:19:26 AM7/1/18
to Django users
You're not returning a response from the view method.  this has nothing to do with setting the value on the model field.

Rakhee Menon

unread,
Jul 3, 2018, 1:24:40 AM7/3/18
to Django users
Yeah! but now I get this error

'required': 'This field is required.', 'null': 'This field may not be null.', 'invalid': 'Invalid data. Expected a dictionary, but got {datatype}.'}
ipdb> serializer.errors
{'cast_weight': ['A valid number is required.']}

In models.py 
cast_weight = models.FloatField(null=True, blank=True)

Jason

unread,
Jul 3, 2018, 12:09:31 PM7/3/18
to Django users
sounds like you didn't make a migration after the change.
Reply all
Reply to author
Forward
0 new messages