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

Question: How can I fill and send a form from code? #1905

Open
Nixellion opened this issue Sep 1, 2019 · 0 comments
Open

Question: How can I fill and send a form from code? #1905

Nixellion opened this issue Sep 1, 2019 · 0 comments

Comments

@Nixellion
Copy link

Nixellion commented Sep 1, 2019

Hi, I'd like to automate some things by creating some entries in the database from code, but I'd like to do it through flask-admin's forms because they do some additional processing on posting. Like Media_Entry that holds images and generates thumbnails on post.

So the question is, how can I instantiate, fill and submit a form\view completely from code? Also passing an image file data to it.

Basically I want to create a multi-image upload view, which instead of connecting multiple images to one db entry will generate multiple entries with common parameters selected by the user, like prefix to generated names.

So far this is what I managed to come up with but it's clearly not right:

image_form = ImageView(Media_Entry)
image_form.name = "{}_{}".format(base_name, i)
image_form.tags = tags
image_form.show_in_header = image_file.stream.read()
image_form.path = image_contents
image_form.update_model()

Thanks!

@Nixellion Nixellion changed the title Question: How can I fill and send a from from code? Question: How can I fill and send a form from code? Sep 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant