MongoEngine / MongoEngine/mongoengine
Add "blank" attribute for document fields.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4h 41m
- Merged PRs (30d)
- 11
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing how MongoEngine document fields currently use required and how mongodbforms maps that setting to Django form requiredness, especially for BooleanField. Define and test blank semantics alongside required, including unchecked BooleanField behavior; done when empty-value validation and form requiredness support the proposed Django-like distinction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, python
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100