You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Django model fields have two attributes "blank" and "null" that can be used for empty value validation, when mongoengine document field has only "required" attribute.
Since mongoengine intends to have minimum amount of differences with django orm, it would be very helpful to have similar behavior about empty values.
We ran into a problem, that made me create this issue:
There's a project, called mongodbforms, that allows to create django forms from mongoengine documents. ModelForm field in django becomes required only when blank==False, so it's possible to forbid field to have empty values on database level and don't make it required in the form.
And, since mongoengine field has only one attribute related to the nullability of the field, mongodbforms has to set required attribute of formfield according to required attribute of mongoengine document.
Best example is BooleanField. Once it's required, form cannot be submitted with unchecked checkbox of this BooleanField due to validation error. So it's impossible to use BooleanField in mongoengine document with required set to True in mongodbforms.
The proposal is to add "blank" attribute to mongoengine document field with the same behavior as "blank" attribute in django model fields.
The text was updated successfully, but these errors were encountered:
Currently the required attribute is pretty much the same as the blank attribute of django's field.
But the null attribute in django is a constraint to the database, whereas in mongoengine it's just a flag to whether use the default value or None.
Django model fields have two attributes "blank" and "null" that can be used for empty value validation, when mongoengine document field has only "required" attribute.
Since mongoengine intends to have minimum amount of differences with django orm, it would be very helpful to have similar behavior about empty values.
We ran into a problem, that made me create this issue:
There's a project, called mongodbforms, that allows to create django forms from mongoengine documents.
ModelForm
field in django becomes required only whenblank==False
, so it's possible to forbid field to have empty values on database level and don't make it required in the form.And, since mongoengine field has only one attribute related to the nullability of the field, mongodbforms has to set required attribute of formfield according to required attribute of mongoengine document.
Best example is
BooleanField
. Once it's required, form cannot be submitted with unchecked checkbox of thisBooleanField
due to validation error. So it's impossible to useBooleanField
in mongoengine document with required set toTrue
in mongodbforms.The proposal is to add "blank" attribute to mongoengine document field with the same behavior as "blank" attribute in django model fields.
The text was updated successfully, but these errors were encountered: