4 ms·
I love writing RESTful services in Flask, but I'm thinking about switching to Django solely because of Django Rest Framework, which seems to be the closest of a
by eric_bullington 14y ago
I love writing RESTful services in Flask, but I'm thinking about switching to Django solely because of Django Rest Framework, which seems to be the closest of all Python REST projects to Fielding's original idea, or what is now being called HATEOAS. It's also extraordinarily well-documented and designed.
Has anyone here used SQLAlchemy with Django Rest Framework? I know it's possible to use SQLAlchemy with Django, but I'm curious if this will cause any issues with Django Rest Framework. I probably won't switch if I can't use SQLAlchemy.
- almost 14y agoYou probably wouldn't be able to use ModelResources (the ones that get fields automatically from the Model, similar to ModelForms) but apart from that I don't see anything that ties Django Rest Framework to Django's ORM
- lucian1900 14y agoA lot of things depend on Django's ORM, admin and REST libraries being the most useful. I once tried to use SQLAlchemy to write some particularly complex queries and used aldjemy[0] for that. While it worked reasonably well for a few queries, it made things a bit confusing by having two ways of querying. It was also annoying to debug things at first (since I was using SQLAlchemy's own executor), so I ended up generating SQL and explicitly feeding that into Django's executor. It's generally a pain to use SQLAlchemy with Django. It's the primary reason I avoid Django. 0. https://github.com/Deepwalker/aldjemy/ https://github.com/Deepwalker/aldjemy/
- tomchristie 14y ago@almost is right - there's nothing that strictly ties you in to Django's ORM. A few thoughts: * You'll need to use the Serializer class rather than the automatic ModelSerializer. * You'll need to do a bit of tweaking if you want to use the Generic class based views (since they default to using the standard Django querysets), but if you're just writing the views yourself there's nothing tying you to the ORM. * You'll need to deal with the transaction management, probably by using middleware something like this: http://stackoverflow.com/questions/6606725/best-way-to-integrate-sqlalchemy-into-a-django-project http://stackoverflow.com/questions/6606725/best-way-to-integ... If it is something you pursue it'd be tremendously helpful if you could post to the list on how you get on.