This repository has been archived by the owner on Apr 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
A bunch of changes and fixes #14
Open
lexqt
wants to merge
42
commits into
wpjunior:master
Choose a base branch
from
lexqt:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
in order to override in subclasses
to be more like original equivalents from Django
`fields_for_document` now returns `None` for fields not supported by formfield generator. Such fields are filtered or replaced later by declared fields in `DocumentFormMetaClass`.
``parent_document`` argument is not obligatory anymore. It can be automatically set if embedded doc has a parent reference (MongoEngine/mongoengine#139). Add basic support for ListField(EmbeddedDocumentField).
Get rid of positional arguments. Use only kwargs to simplify generated fields customization in forms. E.g.: class MyForm(DocumentForm): class Meta: document = MyDoc my_field = default_generator.generate(MyDoc.my_field, formfield_kwarg=custom_value)
Now it's ok to dynamically overwrite field attrs (like `required`) at form initialization.
See Django `ModelForm._post_clean`.
Otherwise we can get unexpected results sometimes. Example: There is a document with "alias" field. Alias is used in all urls incl. update view url. We use UpdateView with DocumentForm, set some field to invalid value and change alias. Our document is not saved because of one invalid field value. Update view is rendered again. But `object` var from context_data is an updated document with another alias. So html form `action` arg is a wrong url pointing to non-existent doc. And we can get 404 error on next form submission.
Better than nothing. TODO: implement something like `BaseModelForm.validate_unique`.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello, @wpjunior.
Maybe I misunderstood something from your mail (whether a new version will be introduced in a current mongotools repo or in some external system only) but anyway I created this pull request just in case.
A bunch of changes and fixes intended to make mongotools views and forms more like their equivalents from Django (v 1.4) and to support more features from MongoEngine (v 0.7-0.8), e.g.: