question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

identity_key is returning an array with 3 arguments and breaking the code

See original GitHub issue

https://github.com/flask-admin/flask-admin/blob/f04b71b78f75c2c5afdb50ceb2acf2ab27811d2b/flask_admin/contrib/sqla/fields.py#L299

I think it should not expect identity_key to return precisely two elements.

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1997, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.6/site-packages/flask_admin/base.py", line 69, in inner
    return self._run_view(f, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/flask_admin/base.py", line 368, in _run_view
    return fn(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/flask_admin/model/base.py", line 2076, in edit_view
    return_url=return_url)
  File "/usr/local/lib/python3.6/site-packages/flask_admin/base.py", line 308, in render
    return render_template(template, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/flask/templating.py", line 134, in render_template
    context, ctx.app)
  File "/usr/local/lib/python3.6/site-packages/flask/templating.py", line 116, in _render
    rv = template.render(context)
  File "/usr/local/lib/python3.6/site-packages/jinja2/asyncsupport.py", line 76, in render
    return original_render(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.6/site-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.6/site-packages/flask_admin/templates/bootstrap3/admin/model/edit.html", line 3, in top-level template code
    {% from 'admin/lib.html' import extra with context %} {# backward compatible #}
  File "/usr/local/lib/python3.6/site-packages/flask_admin/templates/bootstrap3/admin/master.html", line 1, in top-level template code
    {% extends admin_base_template %}
  File "/usr/local/lib/python3.6/site-packages/flask_admin/templates/bootstrap3/admin/base.html", line 37, in top-level template code
    {% block page_body %}
  File "/usr/local/lib/python3.6/site-packages/flask_admin/templates/bootstrap3/admin/base.html", line 77, in block "page_body"
    {% block body %}{% endblock %}
  File "/usr/local/lib/python3.6/site-packages/flask_admin/templates/bootstrap3/admin/model/edit.html", line 32, in block "body"
    {% block edit_form %}
  File "/usr/local/lib/python3.6/site-packages/flask_admin/templates/bootstrap3/admin/model/edit.html", line 33, in block "edit_form"
    {{ lib.render_form(form, return_url, extra(), form_opts) }}
  File "/usr/local/lib/python3.6/site-packages/jinja2/runtime.py", line 579, in _invoke
    rv = self._func(*arguments)
  File "/usr/local/lib/python3.6/site-packages/flask_admin/templates/bootstrap3/admin/lib.html", line 202, in template
    {% call form_tag(action=action) %}
  File "/usr/local/lib/python3.6/site-packages/jinja2/runtime.py", line 579, in _invoke
    rv = self._func(*arguments)
  File "/usr/local/lib/python3.6/site-packages/flask_admin/templates/bootstrap3/admin/lib.html", line 182, in template
    {{ caller() }}
  File "/usr/local/lib/python3.6/site-packages/jinja2/runtime.py", line 579, in _invoke
    rv = self._func(*arguments)
  File "/usr/local/lib/python3.6/site-packages/flask_admin/templates/bootstrap3/admin/lib.html", line 203, in template
    {{ render_form_fields(form, form_opts=form_opts) }}
  File "/usr/local/lib/python3.6/site-packages/jinja2/runtime.py", line 579, in _invoke
    rv = self._func(*arguments)
  File "/usr/local/lib/python3.6/site-packages/flask_admin/templates/bootstrap3/admin/lib.html", line 175, in template
    {{ render_field(form, f, kwargs) }}
  File "/usr/local/lib/python3.6/site-packages/jinja2/runtime.py", line 579, in _invoke
    rv = self._func(*arguments)
  File "/usr/local/lib/python3.6/site-packages/flask_admin/templates/bootstrap3/admin/lib.html", line 130, in template
    {{ field(**kwargs)|safe }}
  File "/usr/local/lib/python3.6/site-packages/wtforms/fields/core.py", line 153, in __call__
    return self.meta.render_field(self, kwargs)
  File "/usr/local/lib/python3.6/site-packages/wtforms/meta.py", line 56, in render_field
    return field.widget(field, **render_kw)
  File "/usr/local/lib/python3.6/site-packages/flask_admin/form/widgets.py", line 28, in __call__
    return super(Select2Widget, self).__call__(field, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/wtforms/widgets/core.py", line 287, in __call__
    for val, label, selected in field.iter_choices():
  File "/usr/local/lib/python3.6/site-packages/flask_admin/contrib/sqla/fields.py", line 109, in iter_choices
    for pk, obj in self._get_object_list():
  File "/usr/local/lib/python3.6/site-packages/flask_admin/contrib/sqla/fields.py", line 102, in _get_object_list
    self._object_list = [(text_type(get_pk(obj)), obj) for obj in query]
  File "/usr/local/lib/python3.6/site-packages/flask_admin/contrib/sqla/fields.py", line 102, in <listcomp>
    self._object_list = [(text_type(get_pk(obj)), obj) for obj in query]
  File "/usr/local/lib/python3.6/site-packages/flask_admin/contrib/sqla/fields.py", line 299, in get_pk_from_identity
    cls, key = identity_key(instance=obj)
ValueError: too many values to unpack (expected 2)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

11reactions
tarzanjwcommented, Jan 8, 2018

For ones who want to work with SQLAlchemy 1.2 and Flask-Admin, use sqlalchemy==1.2.0b3

7reactions
fruechelcommented, Jan 4, 2018

Don’t downgrade this package to 1.1.0, downgrade SQLAlchemy explicitly. Still use the most recent version of this package:

flask-admin
sqlalchemy<1.2

Something like that in requirements.txt.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Pass / Return an Array In Java - Software Testing Help
In this tutorial, we will discuss how to pass arrays as an argument to a method and return the array from the method....
Read more >
d3/d3-array: Array manipulation, ordering, searching ... - GitHub
Returns an array with the rank of each value in the iterable, i.e. the zero-based index of the value when the iterable is...
Read more >
How to Return an Array in Java? - GeeksforGeeks
Here we will discuss how to return an array in java. In order to return an array in java we need to take...
Read more >
Array methods - The Modern JavaScript Tutorial
Arrays provide a lot of methods. To make things easier, in this chapter they are split into groups. Add/remove items.
Read more >
javascript function takes string and returns array - Stack Overflow
I would like to create a function that takes in a string as a parameter and returns an array by breaking up the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found