Closed om-henners closed 1 month ago
issue when using form_choices for dropdown resulting in this error:
(downgrading wtforms to 3.1.2 fixed the issue)
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 1498, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 1476, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.11/site-packages/flask_cors/extension.py", line 176, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/usr/local/lib/python3.11/site-packages/flask_restx/api.py", line 672, in error_router
return original_handler(e)
[Previous lines repeated multiple times]
File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 880, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/usr/local/lib/python3.11/site-packages/flask_admin/base.py", line 76, in inner
return self._run_view(f, *args, **kwargs)
File "/usr/local/lib/python3.11/site-packages/flask_admin/model/base.py", line 2209, in edit_view
return self.render(template, **kwargs)
File "/usr/local/lib/python3.11/site-packages/flask/templating.py", line 150, in render_template
return _render(app, template, context)
File "/usr/local/lib/python3.11/site-packages/flask/templating.py", line 131, in _render
rv = template.render(context)
File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "/usr/local/lib/python3.11/site-packages/flask_admin/templates/bootstrap4/admin/model/edit.html", line 3, in top-level template code
{% from 'admin/lib.html' import extra with context %}
File "/usr/local/lib/python3.11/site-packages/flask_admin/templates/bootstrap4/admin/model/edit.html", line 33, in block 'edit_form'
{{ lib.render_form(form, return_url, extra(), form_opts) }}
File "/usr/local/lib/python3.11/site-packages/jinja2/runtime.py", line 777, in _invoke
rv = self._func(*arguments)
File "/usr/local/lib/python3.11/site-packages/flask_admin/templates/bootstrap4/admin/lib.html", line 146, in template
{{ field(**kwargs) | safe }}
File "/usr/local/lib/python3.11/site-packages/wtforms/fields/core.py", line 164, in __call__
return self.meta.render_field(self, kwargs)
File "/usr/local/lib/python3.11/site-packages/wtforms/meta.py", line 64, in render_field
return field.widget(field, **render_kw)
File "/usr/local/lib/python3.11/site-packages/flask_admin/form/widgets.py", line 23, in __call__
return super(Select2Widget, self).__call__(field, **kwargs)
File "/usr/local/lib/python3.11/site-packages/wtforms/widgets/core.py", line 374, in __call__
val, label, selected, render_kw = choice
ValueError: not enough values to unpack (expected 4, got 3)
cc: @ronyriachy
Please could you provide a minimal reproduction code example to assist with debugging. Thanks :)
Also can you please test this with v2.0.0a - I believe this may have been fixed as well?
Hello, The flask version is 2.0.0a0. In order to reproduce the issue, add form_choices to the view class with any options and open the create or edit view. It gives an error if WTForms version is 3.2.1 (which is the newest version).
When we downgraded to 3.1.2, it worked fine
On Sat, 26 Oct 2024, 19:20 Samuel Williams, @.***> wrote:
Also can you please test this with v2.0.0a - I believe this may have been fixed as well?
— Reply to this email directly, view it on GitHub https://github.com/pallets-eco/flask-admin/issues/2548#issuecomment-2439639056, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3VO4UL53HJ244NH6PXL65LZ5O6LPAVCNFSM6AAAAABQQCQ4QCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMZZGYZTSMBVGY . You are receiving this because you were mentioned.Message ID: @.***>
I think yours and @Adham-neo's issue is different than the one in the original post of this issue, however should be fixed by https://github.com/pallets-eco/flask-admin/pull/2551 that I will look to get in shortly.
Both of the issues mentioned in this thread should be fixed by either v2.0.0a0 or v2.0.0a1 (just published).
I will close this off for now.
Thanks for reporting it 🙇
Thanks to you!
On Sat, 26 Oct 2024, 21:16 Samuel Williams, @.***> wrote:
Both of the issues mentioned in this thread should be fixed by either v2.0.0a0 or v2.0.0a1 (just published).
I will close this off for now.
Thanks for reporting it 🙇
— Reply to this email directly, view it on GitHub https://github.com/pallets-eco/flask-admin/issues/2548#issuecomment-2439681697, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3VO4UMHKD62UN5LIKD6XUTZ5PL6NAVCNFSM6AAAAABQQCQ4QCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMZZGY4DCNRZG4 . You are receiving this because you were mentioned.Message ID: @.***>
After updating to wtforms 3.2.1I get the following errors:
Environment: