4 ms·
The ORM is the only weak point, the rest is widely considered stable and of quality.
by lucian1900 5y ago
The ORM is the only weak point, the rest is widely considered stable and of quality.
- amanzi 5y agoWhat's weak about the ORM? I've been working with Django for the last year or so and find the ORM great, but I don't have much experiences with other ORMs to compare to.
- lucian1900 5y agoIt lacks a unit of work system to allow precise control over loading and saving data. It also lacks an abstraction for composing arbitrary SQL queries out of components. It’s sometimes very difficult to predict the number of queries that will be emitted. It’s a reasonable ORM, but doesn’t compare to SQLAlchemy.
- theptip 5y agoI strongly agree with this; while the ORM is great for simple/medium complexity use-cases, it really lacks the flexibility to extend into more complex domains. SQLAlchemy can hit all the Django ORM's use-cases, and also can be used for a bunch of designs that the Django ORM simply cannot support. A dirty-tracking mode would be great. This is really useful if you want to have code that builds up a list of sub-objects, and then _maybe_ commits them, but maybe rolls back after creating most of the Python objects. The naive Python you want to write is `for i in range(10): foo.bars.add(Bar(i))` which in the Django ORM triggers a DB write for each bar, even if you error out on the 10th Bar. As you say, another area where the ORM can bite you is the always-on foreign-key-traversal logic. So if you have loaded model foo, then accessing foo.bar will trigger a SQL query under the covers, if you didn't select_related/prefetch_related properly. This is great for simple use-cases and exploratory coding, but can make it very easy to write code with horrendous performance. Naively-coded views often have hundreds of DB lookups and it's hard to track down where these are coming from when the app is complex and especially when you've got _some_ *_related in place, but you're missing a prefetch somewhere.
- weird-eye-issue 5y agoDjango's ORM is pretty incredible actually. I've been able to do some very advanced queries including window functions, several subqueries, even recursive CTEs...
- suvelx 5y agoWhat makes you think it's the weak point? Imo the ORM is easily the best bit. The request-handling and template rendering is in my mind the weakpoint.
- livre 5y agoI agree with this, I've been using Django for more than a couple of years. The built-in admin interface is a blessing, the ORM is good enough and unless you are handling very huge loads it doesn't matter if it doesn't always generate the most efficient queries (in more than 5 years I've never run into any issues with that). The almost but not exactly MVC pattern that also let's you mix both class and function based views coupled with a very limited template system is a curse. I would have preferred one way to do things(TM) but the Django approach let's you badly do a hundred and more different ways if you aren't very experienced with it (and even if you are you need a lot of discipline to do things properly, and even if you have discipline sometimes Django doesn't have a feature you need so you implement your own and then a major release comes and now it has its own incompatible way of doing the same thing). I still wouldn't change Django for anything else, I'm sure I wouldn't have a job anymore if it weren't for how fast and easily I can implement things with it (management is an absolute hell here and changes how everything is done every couple of months until management itself gets fired and replaced every year or two).