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

render_table() without SQLAlchemy not working #242

Closed
vpathuis opened this issue Aug 23, 2022 · 5 comments · Fixed by #243
Closed

render_table() without SQLAlchemy not working #242

vpathuis opened this issue Aug 23, 2022 · 5 comments · Fixed by #243
Labels

Comments

@vpathuis
Copy link

vpathuis commented Aug 23, 2022

For render_table(), the documentation states: data – An iterable of data objects to render. Can be dicts or class objects.
When I try using this macro on a simple test list, I get an error: AttributeError: 'Item' object has no attribute '__table__'.
It seems that SQLAlchemy is supposed to supply objects with __table__. All examples I've found use SQLAlchemy.

This is the test list:

@dataclass
class Item:
    col1: int
    col2: str

testlist = [
        Item(1, '2'),
        Item(3, '4')
    ]

Is using SQLAlchemy a requirement? If so, is the documentation correct?

@PanderMusubi
Copy link
Collaborator

Please see #243

@vpathuis
Copy link
Author

Works perfect!
The issue was not in the data but in the titles, which I'd assumed optional. I missed this sentence: if not provided, will automatically detect on provided data, currently only support SQLAlchemy object.
Thanks a lot for reacting, and so quickly!

@vpathuis
Copy link
Author

Could it be there is a similar simple solution for using the action buttons? When I use show_actions = True and add a model (class) and an edit_url, I get jinja2.exceptions.UndefinedError: 'type object' has no attribute 'query'.

@PanderMusubi
Copy link
Collaborator

Sounds like SQLAlchemy is needed for that, or you need your class to implement that. See base/table.html line 11.

@vpathuis
Copy link
Author

Thnx for the suggestion. I'll consider my options :) Great work anyhow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants