当前位置: 动力学知识库 > 问答 > 编程问答 >

python - Where should model-related operations reside in Flask?

问题描述:

I have a Flask app with several models. I've put them in a models folder like so:

models/

__init__.py

user.py

...

In each file, I've declared the Flask-SQLAlchemy equivalent on the model (class with table columns as attributes).

Now, where should I put model-related operations? Say I need to do something special before each user save; or define a much used query; or connect to third-party services.

Also, if I have some wrappers to third-party services, defined as classes, where should I put them in my app directory tree?

分享给朋友:
您可能感兴趣的文章:
随机阅读: