django-rest-framework-mongoengine icon indicating copy to clipboard operation
django-rest-framework-mongoengine copied to clipboard

Serializer Field: `default=0` gets ignored

Open acu192 opened this issue 4 years ago • 1 comments

Because of this line: https://github.com/umutbozkurt/django-rest-framework-mongoengine/blob/2ab11b39428f5c3ecc0712885884e3c325528e66/rest_framework_mongoengine/utils.py#L147

If default is "falsy" (like if you do default=0 on an IntField) then the default is ignored.

acu192 avatar Jun 24 '21 04:06 acu192

A workaround is to do default=lambda: 0 on your ME fields, instead of just the simple default=0.

acu192 avatar Jun 24 '21 04:06 acu192