Live data from Hacker News

What I love about Django

buttondown.com

51–60 of 120 posts

Re: What I love about Django

#51

I haven’t used Django for a long time but when I did I found it one of the best documented projects out there.

Sometimes I find the examples lacking a bit. For example: https://docs.djangoproject.com/en/6.0/ref/class-based-views/... Each view deserves an example, that uses the most relevant fields to specify the behavior of that view, and perhaps a minimal template example for rendering that view, and at least one of the examples should be using forms.

This is where asking an LLM for an example is very useful, but ideally, I should be able to find the available fields and their explanation and when to use them at a glance in the docs.

In general the docs are good, just examples could be better.

Re: What I love about Django

#52
post #6

Django is boring, which is why it works well. Use the ORM together with DRF serializers and an OpenApi generator and you can create TS types and TS client directly from your API. Works incredibly well almost straight out of the box for even quite large applications. Once you start to grow out of it, it's easy to bypass the ORM and write raw sql queries. You also won't be re-writing your backend every few years, the c…

If the DRF stack seamless like Ninja now?

Ninja is quite a heavyweight in terms of dependencies (depends on Pydantic, which is itself heavyweight). Not everyone wants that in their project.

Re: What I love about Django

#53
post #15

Earlier quoted context omitted.

The DHH hate is absolutely crazy on HN. I don't understand how people can be so out of touch.

It's not hate, it's not wanted to be associated with: see https://victorwynne.com/dhh/

I need to go look up the CEO of my refrigerator, dishwasher, couch, car, cell phone, TV, shirt and jeans, and oat milk to see if they said anything I disagree with on social media so I can boycott them.

Re: What I love about Django

#54
post #50

Earlier quoted context omitted.

The ORM is really not good in my opinion because it is ActiveRecord'ish and has all its downsides. I wouldn't use Django for any moderately complex domain. But even with simpler CRUD style apps I don't really see the point in it.

What would you have done Instagram from instead of Django?

Elixir and Phoenix.

Re: What I love about Django

#56
post #38

Earlier quoted context omitted.

Yes, if you attempt to use Django like you'd use your typical Java, Swift, C#, or Objective-C framework, you're not going to have a good time. I've seen the horrors Java devs start doing on a Python project when trying to "fix" things, where by "fix" they mean use patterns they had to in previous gigs. It's a different world.

Having basic defensive programming, some simple classes instead of dicts everywhere and avoiding n+1 is a "different world"?

Just asking these questions underscores lack of understanding how things are usually done in Django and Python in general.

In Django you'd typically use simple classes (models or forms, or even dataclasses nowadays) more than dicts everywhere; n+1 is trivially avoidable (as another sibling comment points out, and you also have multiple packages that autodetect such cases if you've missed them).

Python in general has a more "consenting adults" than "defensive programming" attitude (which doesn't mean exessive coupling or spaghetti, but the approach is different from the Java or C# mindset).

There's no one THE correct style of programming.

Re: What I love about Django

#58
I'd love Django, if they had a better async story ... I used it for a recent project. While the framework is overall amazing, I had to switch to Go for better performance and easier async support.

Re: What I love about Django

#59

I really like the ORM and the migrations, but some parts I really dislike. They're maybe not Django's fault, but how it's used most places: * Models being passed around everywhere, queries happening everywhere. I prefer having a dedicated service/selector layer to do those things. Then convert to pydantic objects or something that's passed around further. * Corollary, but adding stuff to querymanagers quickly goes ou…

The ORM is really not good in my opinion because it is ActiveRecord'ish and has all its downsides. I wouldn't use Django for any moderately complex domain. But even with simpler CRUD style apps I don't really see the point in it.

The one thing I really appreciate with the ORM is that you really can get the ORM to make... more or less any sort of SQL query you want.

It can take a while to wrap your head around what fields get used in aggregates and the like, but when working with big models with like 65 fields and juggling a bunch of stuff, not having to futz with serialization/deserialization and "just" expressing your problem in the dumb way is nice.

I want to say this all comes back to bite you in the end but honestly it's more just having wide tables that comes to bite you. A service layer wouldn't really save you. Meanwhile you save yourself a bunch of tedium in the mean time

Re: What I love about Django

#60

I really like the ORM and the migrations, but some parts I really dislike. They're maybe not Django's fault, but how it's used most places: * Models being passed around everywhere, queries happening everywhere. I prefer having a dedicated service/selector layer to do those things. Then convert to pydantic objects or something that's passed around further. * Corollary, but adding stuff to querymanagers quickly goes ou…

The ORM is really not good in my opinion because it is ActiveRecord'ish and has all its downsides. I wouldn't use Django for any moderately complex domain. But even with simpler CRUD style apps I don't really see the point in it.

I mean if you're doing it this way, you're really not applying best practices as a developer (never mind as a Django developer).

> Models being passed around everywhere, queries happening everywhere.

No, as a developer you still need to be 100% aware of the underlying queries and potential performance issues. No excuse for N+1 problems. ORM is not an excuse to be lazy, but I admit it will probably catch quite a few developers.

Those same developers would probably make a mess out of any other framework or technology though.

Post reply on HN