asif-mahmud / eve_runner

Eve project template for large applications
https://asif-mahmud.github.io/eve_runner/
GNU General Public License v2.0
4 stars 0 forks source link

ORM Model register failed #1

Open wadehehe opened 4 years ago

wadehehe commented 4 years ago

Base._decl_class_registry can not find a key 'tablename'

What reason cause this?

I have already inherit BaseModel

asif-mahmud commented 4 years ago

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

asif-mahmud commented 4 years ago

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

wadehehe commented 4 years ago

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

asif-mahmud commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

no no, you have to use db.Base not the ModelBase.

Best wishes - Asif Mahmud Shimon

On Thu, Mar 5, 2020 at 4:21 PM wadehehe notifications@github.com wrote:

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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/asif-mahmud/eve_runner/issues/1?email_source=notifications&email_token=ABLQLUQMUNXT5SR3ALOXQN3RF54LPA5CNFSM4LBB4C5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEN4UFSQ#issuecomment-595149514, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLQLUWWRK6ORU5WPF5VL2TRF54LPANCNFSM4LBB4C5A .