News for hackers. Stuff that matters.
Re:Django 4.0 release candidate 1 released by BozeWolf on Monday November 22, 2021 @04:12AM (#29304400)
There are cooler frameworks, there are more minimal frameworks, there are more "modern" frameworks. Whatever that means. Yes I would like to work with FastAPI, it is great. But...

Django gets the shit done. There are plenty of developers to find for it. Lots of good quality plugins. Every problem you have, infrastructure wise, is often already solved and there is a blog post of it.

Its good parts and its bad parts are widely written about. And if that is not enough: the documentation is great.

Great framework to get your product to market, it allows me to focus on building products. I dont want to think about routing forms processing, or project layout again. I want to write code for the product, not for the framework. Django is just good enough. Forms, URL routing and models are not what delivers value to products I am working on. So I don't want to spend time on it.

Remember: no customer cares about your product being run on cool-async-framework-X. Customers just want a good looking and good working product.

Re:Django 4.0 release candidate 1 released by top_sigrid on Monday November 22, 2021 @04:53AM (#29304662)
While I have no experience with Django, this could exactly be said about Rails. It's great these two exist and are being worked on for so long and have this level of maturity.
Re:Django 4.0 release candidate 1 released by ksec on Monday November 22, 2021 @09:59AM (#29306940)
I wonder why Django seems to have a easier time in hiring, considering it should be a smaller market than Rails. Even on HN monthly hiring list Rails and Django open positions is roughly 3:1. And yet I rarely hear Django people ever complain about the lack of talent pool.
Re:Django 4.0 release candidate 1 released by csdreamer7 on Monday November 22, 2021 @03:11PM (#29311058)
As a former Rails dev, my two cents is that the language keeps breaking.

The small changes in 2.7 were understandable, but quiet a few gems that I used broke in 2.4, and in 2.5. It was a pain to fix, some were never updated.

Much how people complain that changing strings in Python 2->3 hurt adoption; we have had breaking changes that can break gems almost every release.

Ruby is a great language, but Python is so much less stressful, easier to find working libraries, and easier to find jobs. The last reason is likely because of the first two.

It is fine to add things, but when you keep changing the language and breaking things; people hesitate to write software in it. There is a reason the Linux kernel has a rule about (almost) never breaking user-space.

Re:Django 4.0 release candidate 1 released by smoe on Monday November 22, 2021 @10:22AM (#29307267)
I reckon, Ruby and Rails while still heavily used has fallen out of fashion since it's peak time, whereas Python has gotten a huge boost in recent years from data science and being a common teaching language which spilled over to other uses of the language.

In the mid 2010s the python web application space felt very stagnant to me, many semi abandoned projects, lots of people leaving for other technologies. But there has been quite some reversal on that since.

Re:Django 4.0 release candidate 1 released by traverseda on Monday November 22, 2021 @10:23AM (#29307281)
Python is a very popular language, and if you know Python Django is easy.
Re:Django 4.0 release candidate 1 released by sireat on Monday November 22, 2021 @01:33PM (#29309955)
Django seems to add too much magic for me. It is mostly manage.py this manage.py that.

I can't grok it completely. All the books that I read on it skipped the architecture part.

Maybe there is a good guide to Django architecture - the big picture?

PS I am rather experienced in Python (Numpy, Pandas, Plotly, Flask, SQLAlchemy, FastAPI, BeautifulSoup are my bread and butter)

Re:Django 4.0 release candidate 1 released by derekjdanserl on Monday November 22, 2021 @01:59PM (#29310273)
You list a bunch of libraries, but Django is not a library. It is a framework.

The Django file structure, for example, is not exactly optional in Django. Realize FastAPI follows in the footsteps of Flask. Neither FastAPI or Flask are frameworks. As a FastAPI user myself, I do think it’s closer to a happy medium, but it’s nothing remotely comparable to Django.

When using Django, the best advice I have is to dive all the way in. Follow the docs and the best practices first. Besides, manage.py is just like having a well-developed kit of shell scripts/ in your repo.

Re:Django 4.0 release candidate 1 released by sireat on Monday November 22, 2021 @02:53PM (#29310886)
I am well aware that Django is a framework and yes it is quite strict about the way you set it up.

That is a reasonable price to pay for the batteries included approach.

What I am saying that I do not grok the big picture of Django flow.

For some reason I got up to speed with Laravel much faster and I do not write much PHP.

The books that I skimmed (like recommended Two Scoops of Django) just go into various things you can do but do not show the big picture.

Re:Django 4.0 release candidate 1 released by traverseda on Monday November 22, 2021 @04:12PM (#29311617)
You write views, and they render templates. There's a file called `urls.py` where you import a view and attach it to an actual url.

So

    appconfig/urls.py depends on
    yourapp/views.py which renders html using a template at
    yourapp/templates/sometemplate.html
Presuming that you want to interact with the database `yourapp/views.py` probably also depends on models from `yourapp/models.py` or some other apps database model.
Re:Django 4.0 release candidate 1 released by adamauckland on Monday November 22, 2021 @06:36AM (#29305299)
yes, they are very similar. I'm not sure if Rails has quite the level of auto-generating admin system, though.
Re:Django 4.0 release candidate 1 released by the-dude on Monday November 22, 2021 @06:43AM (#29305335)
Probably better, just not in base.
Re:Django 4.0 release candidate 1 released by gosukiwi on Monday November 22, 2021 @09:30AM (#29306632)
There's ActiveAdmin which basically that.
Re:Django 4.0 release candidate 1 released by blitzar on Monday November 22, 2021 @04:29AM (#29304514)
I end up spending more time writing the CSS than the Django...
Re:Django 4.0 release candidate 1 released by privacyonsec on Monday November 22, 2021 @04:19AM (#29304458)
agreed, I'm more convinced now that django is really enough and get shit done even if there a poor support of async, more convinced after reading this blog post that async python is not faster (was on hn) : https://calpaterson.com/async-python-is-not-faster.html
Re:Django 4.0 release candidate 1 released by Uberphallus on Monday November 22, 2021 @04:56AM (#29304688)
It's not significantly faster (or slower), it's the author that doesn't know how to run a benchmark. You can read my take on his take [0].

Leaving that aside, async is very advisable (even a must) if your backend throws requests against external and potentially blocking services and you want to keep answering your own clients without scaling for no reason.

[0]https://news.ycombinator.com/item?id=29128107

Re:Django 4.0 release candidate 1 released by emacsen on Monday November 22, 2021 @07:01AM (#29305457)
This is a question that's largely impossible to answer, but there's a performance vs developer (or business) time calculation to be made.

More aptly, if one can throw another physical server at it, is it worth fixing the underlying performance issue?

Sometimes the answer is yes. If you're at a place with even a thousand physical servers running your process and you can save 2% overall performance with a rewrite, that's saving you 20 physical servers worth of performance.

But often the answer is that it's not worth it. That 2% performance increase on a set of 10 servers is not calculable, and more often even a 10% performance benefit is only noticeable on some specific task, not as a constant overhead.

On the other hand, developer time is expensive and can often be best spend on core functionality.

If Django is, let's say even 20% slower than an async framework like FastAPI, but it's going to save three developers a week of development time to implement a feature in Django, then that's probably a much cheaper solution.

I've used Django, Flask, Sanic and FastAPI[1] and today I often choose FastAPI for my projects, but I think Django is still what I'd turn to if I needed to make a full fledged web application quickly, despite its performance not being as good as FastAPI.

[1] Before I learned Django, I also used Zope, and TurboGears.

Re:Django 4.0 release candidate 1 released by Zababa on Monday November 22, 2021 @07:19AM (#29305560)
That remind me of a meeting a few days ago where we were discussing if we should add another server or spend a bit more time developing something. After some time, I asked about the server cost, and it ended up being something like 100€ a month more to not have to worry about performance for the next year. In that case the decision was easy enough, but maybe some organisations have fixed server budgets and developers. For those, being able to trade developer time for performance, even if it seems inefficient, may be better than nothing.
Re:Django 4.0 release candidate 1 released by emacsen on Monday November 22, 2021 @10:55AM (#29307748)
Yes, 100% it depends on many factors. 100€ euro a month = 1200€ euro a year... Now if a developer can address that in 15 minutes- wonderful, but if it takes her a week... have you won very much, because it's not just the time calculation but it's the other would this same developer could have been doing in this same time.

Moreover, you're right to calculate this per year because maybe you'll throw this entire code away in a year, or maybe it will become the key code for something else, and you'll need to optimize it anyway.

Even sometimes having a meeting to discuss the performance is not cost effective. Six employees around a table for an hour discussing whether or not to improve the performance of 1200€ a year is not cost efficient.

But then again, sometimes it really is. In one environment we were asked to use some tooling on top of the OS that reduced performance by 5%. It was some management toy that would have made the Linux boxes do the same thing as the Windows boxes, but there was a performance penalty of 5%...

5% of 1000 machines is 50 machines, or just over one rack of servers, and so we could go back to management and say "The performance penalty of this is over a rack of machines. Are you sure you want this?" and then they can decide if it's worth it or not.

Re:Django 4.0 release candidate 1 released by Hamuko on Monday November 22, 2021 @07:28AM (#29305608)
Server upgrade costs can vary wildly depending on what it entails. The cost of adjusting your EC2 Auto-Scaling Group maximum instance count will be very different than contacting HPE sales department.
Re:Django 4.0 release candidate 1 released by marcosdumay on Monday November 22, 2021 @08:29AM (#29306095)
At this point it seems that only mainframes can get more expensive than cloud auto-scaling.

But yeah, some places have a very expensive acquisition procedure. To the point that the labor in buying expensive things costs more than the thing itself. But those places "solve" the problem by buying large batches, and the hardware x developer costs comparison don't change much.

Re:Django 4.0 release candidate 1 released by konschubert on Monday November 22, 2021 @04:59AM (#29304713)
> if your backend throws requests against external (and potentially blocking) services and you have the "audacity" of wanting to keep answering your clients.

If you have enough processes/threads running, the CPU scheduler should take care of that , no?

Re:Django 4.0 release candidate 1 released by fer on Monday November 22, 2021 @05:06AM (#29304768)
Yes, but more processes means more memory footprint, almost 4 times as much in that benchmark, something the author didn't cover. Threading solves that, but it's way more prone to shooting yourself in the foot than async, especially since it's not baked into Django (i.e. you gotta cook your own solutions over callbacks, polling, etc).
Re:Django 4.0 release candidate 1 released by Zababa on Monday November 22, 2021 @07:17AM (#29305548)
Interesting, those results are the opposite of the techempower frameworks, which find that the async frameworks are always faster: https://www.techempower.com/benchmarks/#section=data-r20&hw=.... Though in general I'm not sure about the value of bringing async to Django. If you want more performance, you can already either throw more machines at it, or isolate some part in a service that can be written with FastAPI/Go/something. Async in general makes the code more complex and harder to write, which seems to be the opposite of what Django is for.
Re:Django 4.0 release candidate 1 released by shagmin on Monday November 22, 2021 @10:02AM (#29306982)
For an alternative to async, with better support (granted the use cases aren't exactly the same), you can hand off some processing to Celery and then get the result to the user via Channels.
Re:Django 4.0 release candidate 1 released by mracette on Monday November 22, 2021 @09:11AM (#29306436)
It's also quite easy to swap out the templating engine for whatever front end framework that you'd like to use. Django provides tons of value even when used solely as an API server and ORM.
Re:Django 4.0 release candidate 1 released by selimnairb on Monday November 22, 2021 @09:16AM (#29306490)
And the admin framework is great for accelerating development, making it really easy to create test data as you build out your API.
Re:Django 4.0 release candidate 1 released by falcor84 on Monday November 22, 2021 @09:07AM (#29306400)
Agreed. Although I usually hate marketing taglines, I think Django quite realizes its tagline of "The web framework for perfectionists with deadlines."