belongs_to in User model #308
-
Hi, How can I define a FK field with belongs_to in User model The problem is that any class (Model) does not exist before User
I get: And if I change the order of definition I get:
AttributeError: 'Database' object has no attribute 'User' Best Regards |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@josejachuf you can call db.define_models(MyModel)
auth = Auth(app, db, user_model=User)
db.define_models(AnotherModel)
|
Beta Was this translation helpful? Give feedback.
-
Awesome, I didn't know you could do that. Thanks @gi0baro |
Beta Was this translation helpful? Give feedback.
@josejachuf you can call
define_models
how many times you prefer, just define auth models ancestors before, eg: