I have a Python CLI program, with SQL database models and want to add a frontend with a MVC framework (such as Django). What's the best way to interface my program with the framework, if I've already defined my models?
Do I either:
Choice #1: Shared Model
My Program / | \ Binaries Model Classes | Django / \ View Controller
Choice #2: Create a Bridging Library
My Program / | \ Binaries Model Classes | My-Bridge | Django / | \ View Model Controller
Choice #3: Use Django for Most Work and Remove Model from My Program
Classes \ My Program / | Binaries | | My-Bridge | Django / | \ View Model Controller
I'm avoiding Choice #1 (Create a Shared Model) because I don't know how to create a shared model using Django's ORM and SQLAlchemy.
I'm unsure about Choice #2 (Creating a Bridge) because I don't know if this uses Django to its full extent. From the documentation, it seems as thought Django should handle the Model, given that its a MVC framework.
I'm also avoiding Choice #3 (Removing the Model from Program) because I would have to re-write all the SQLAlchemy ORM logic that uses the SQLAlchemy model in My-Program.
What do you guys think? Which choice is best given that I've already written the CLI version of my program?
I love Django but given this scenario, you could also take a look at Pylons too, since they support SQLAlchemy. Or you can still work with SQLAlchemy by importing it into your views. See this post on an example for doing that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With