[Flask] splitting models into blueprints

Robert Grant robertlagrant at gmail.com
Wed Sep 28 16:30:13 EDT 2016


You can import a model from another file and refer to it directly. Does
that do what you want?


Rob

Sent from my phoneFrom: Alex Alex
Sent: ‎28/‎09/‎2016 20:19
To: flask
Subject: [Flask] splitting models into blueprints
Hi,
Up to this point I've been using single models file in mine main
package that contains all flask blueprints but since models tend to
grow quickly and the file starts to be unreadable I'd like to split
model definition between separate blueprints: for example I have a
blueprint dealing with users so all user related models could be
stored there. The potential problem I see are relations between
different models blueprints. The simple solution I see it to use
__tablename__ to enforce proper
table name through SQLAlchemy and use those names across blueprints.
So my question is: are there any best practices or tips regarding such
design? The only tips I've found so far are about moving models into
separate file not across different blueprints. Please note that my
models have also number of relations (both one-to-many and
many-to-many).
Best Regards,
Alex







_______________________________________________
Flask mailing list
Flask at python.org
https://mail.python.org/mailman/listinfo/flask


More information about the Flask mailing list