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

ORM Model register failed #1

Open
wadehehe opened this issue Mar 4, 2020 · 6 comments
Open

ORM Model register failed #1

wadehehe opened this issue Mar 4, 2020 · 6 comments

Comments

@wadehehe
Copy link

wadehehe commented Mar 4, 2020

Base._decl_class_registry can not find a key 'tablename'

What reason cause this?

I have already inherit BaseModel

@asif-mahmud
Copy link
Owner

did you declare __tablename__ in your model class ? if not that should be the reason.

@asif-mahmud
Copy link
Owner

asif-mahmud commented Mar 4, 2020

BTW, you should utilize db.ModelBase for database models, it handles the tablename internally. check the source in instance/db.py -> ModelBase

@wadehehe
Copy link
Author

wadehehe commented Mar 5, 2020

Yes I declare it. I think i have resolved it , ModelBase should inherit Sqlalchemy Model not Object.

@asif-mahmud
Copy link
Owner

sorry, i had to recheck my own reply, its in the git's readme file - you have to use instance.db.Base as your model's base. that will do.

@wadehehe
Copy link
Author

wadehehe commented Mar 5, 2020

Thanks ,I also try with instance.db.Base ,but it also not working.
I think _decl_class_registry is sqlalchemy attribute, so we must use it as ModelBase's base.

@asif-mahmud
Copy link
Owner

asif-mahmud commented Mar 6, 2020 via email

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

2 participants