[Flask] splitting models into blueprints

Alex Alex alex-alex-90 at wp.pl
Wed Sep 28 15:19:12 EDT 2016

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,


More information about the Flask mailing list