Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only= does not work if model_form is EmbeddedDocument #376

Open
Alexmod opened this issue Feb 6, 2020 · 1 comment
Open

only= does not work if model_form is EmbeddedDocument #376

Alexmod opened this issue Feb 6, 2020 · 1 comment
Labels
decision: wontfix This will not be worked on question type: enhancement Enhancement update for old feature

Comments

@Alexmod
Copy link

Alexmod commented Feb 6, 2020

Example:

class Profile(db.EmbeddedDocument):     
    login = db.StringField()            
    pw_hash = db.StringField()    
    admin = db.BooleanField()     

                                                                                       
class Users(db.Document):      
    _id = db.ObjectIdField()
    stocks = db.DictField() 
    profile = db.EmbeddedDocumentField(Profile) 

If I use exclude like this, then everything is OK:

from flask_mongoengine.wtf import model_form 

form = model_form(Users, exclude=('profile__login'))(request.form)

And the form is generated without the field login.

But if I do like this:

form = model_form(Users, only=('profile__login'))(request.form)

Then nothing is generated.
I use flask-mongoengine Version 0.9.5

P.S.: Thanks to maintainers who support this project.

@insspb
Copy link
Collaborator

insspb commented Jul 24, 2022

@Alexmod
Thank you for report, and excuse for long answer. In general we are not supporting profile__login style syntax for form fields include exclude. Fields are not provided in this style by mongoengine.

But for interest, I checked how you got such results.

Not clear what you mean under first statement, with exclude, when you say that everything is OK. I checked in debug logger right on you example, and I still see login field. Maybe you did not found it.

Screenshot_20220724_064150

For only case everything is simple, such field completely not exist under Users, so you got nothing.

I will keep this case in head, but closing this issue, as pretty sure that it will be very hard and dirty to implement. At least for old model_form. I am working on version 2.0.0 with new forms generator, maybe I will include workaround there.

@insspb insspb closed this as completed Jul 24, 2022
@insspb insspb added question type: enhancement Enhancement update for old feature labels Jul 24, 2022
@insspb insspb reopened this Jul 24, 2022
@insspb insspb added the decision: wontfix This will not be worked on label Jul 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
decision: wontfix This will not be worked on question type: enhancement Enhancement update for old feature
Projects
None yet
Development

No branches or pull requests

2 participants