Like Pinterest and others I want to make great apps in Django. Many of them are talking about limitations of Django ORM - Pinterest are using only one table in Django ORM. I think it can be User table or django_session. It is because they had started with Django ORM.
So, if I am going develop and promote my site for a long time, what solution should I choose? I am going to stay with django, and not switch to flask or nodeJS.
Some django experts are modifying Djagno ORM, sessions, etc. e.g. https://github.com/devhub/baph.
But is it a bit risky for me and I can't use many of Django features like sessions, reset password. However, some great apps work also with SqlAlchemy like: django-tastypie.
But of course the database is the most important, and it must easily evolve to always be fast.
So what solution should I use? Is it no problem to use Django ORM for the User and django session table? For the rest I will use sqlAlchemy. So I can use django-registration, sessions, etc.
Can you see any problems in this solution?
Main difference is that Django ORM uses the “active record implementation”, and SQL Alchemy uses “data mapper implementation”. It means that Django ORM cannot use our models for queries if every row is not linked with the overall model object.
In addition to this, since it interacts directly with the database, you can simply run the queries against the database without actually using the ORM. Plus, SQLAlchemy is much more powerful than Django, albeit with a little higher learning curve.
ORM is an acronym for the object-relational mapper. The ORM's main goal is to transmit data between a relational database and application model. The ORM automates this transmission, such that the developer need not write any SQL. ORM, as from the name, maps objects attributes to respective table fields.
One of the most powerful features of Django is its Object-Relational Mapper (ORM), which enables you to interact with your database, like you would with SQL.
There is kind of a general rule that Django works fine as long as you do it the Django way. In this context it means that you will most likely run into some unexpected problems and have a lot of effort if you want to use SQLAlchemy inside of Django.
Django's ORM is fine. It is not as good as SQLAlchemy (personal opinion) but it get's the job done very well. So my recommendation is: Unless you have a very good reason to use SQLAlchemy and are sure it is worth the effort, just use the Django ORM for everything.
However, if there are good reasons to not use it, then you can replace it and work with SQLAlchemy. As you already described, leaving default Django tables in the ORM will save you some of the pain involved here, so that is a good idea, too.
And finally, Django might not even be your best solution. If you already know Django and know that it is what you want then use it. Otherwise, you could also look around if there are no other frameworks you like better (in the near range to Django I only know of Pyramid, for smaller apps a microframework might suffice).
Edit: To accomodate your comments, here are some more details:
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