Live data from Hacker News

Django 4.0 release candidate 1 released

djangoproject.com

111–120 of 126 posts

Re: Django 4.0 release candidate 1 released

#111
post #82

Earlier quoted context omitted.

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.

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.

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

#112
One thing I've never been able to figure out with Django is how to properly handle javascript. How do you all handle stuff like js dependencies? What I do now is just copy and paste a dependency like mapboxjs and keep it in the static folder. Would be great if I could use node or something like that and then have a way to import js dependencies in django templates. I've been using htmx and alpine js to sprinkle some js into my templates, but maintaining all of those js files always feel so clunky

Re: Django 4.0 release candidate 1 released

#113
post #110

Earlier quoted context omitted.

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 t…

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 y…

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

#114

I love Django and have been using it for many many years. Lately, however, I’ve been finding it increasingly difficult not to be annoyed by some aspects of the developer experience. For example I’d choose React + Typescript over Django templates any time of the day.

Not a Django person, but I've used a few server-side templating languages, and I agree. I'd love to go mostly/entirely server-side, cut down on boilerplate AJAX calls, and ship smaller/less JS-heavy sites to the browser. But I'd also like to write my view logic in a full language, with typechecking and a solid developer experience. I'm hopeful React Server Components will help with at least some of this.

Re: Django 4.0 release candidate 1 released

#115
My favorite new additions:

- django.core.cache.backends.redis.RedisCache cache backend provides built-in support for caching with Redis

- The runserver management command now supports the --skip-checks option.

- The shell command now respects sys.__interactivehook__ at startup. This allows loading shell history between interactive sessions. As a consequence, readline is no longer loaded if running in isolated mode.

- New QuerySet.contains(obj) method returns whether the queryset contains the given object. This tries to perform the query in the simplest and fastest way possible.

- Lookup expressions may now be used in QuerySet annotations, aggregations, and directly in filters.

Re: Django 4.0 release candidate 1 released

#116
post #31

Earlier quoted context omitted.

I used Django for 4 years, their ORM is a mess imo. I wouldn't expect someone new to it to be able to discover how to do this after a couple of hours of reading.

That might be a matter of taste, or which ORM you've used previously. Personally I think it's the only sort of okay ORM, besides Go's sqlx, which is barely an ORM. You do need to have the documentation handy, and writing efficient queries can be tricky, but it is the ORM that makes the most sense to me, and the easiest to get started with.

Have you tried SqlAlchemy? I liked that it felt a lot more like writing sql, whereas Django feels like trying to force a different model on top.

Re: Django 4.0 release candidate 1 released

#117

One thing I've never been able to figure out with Django is how to properly handle javascript. How do you all handle stuff like js dependencies? What I do now is just copy and paste a dependency like mapboxjs and keep it in the static folder. Would be great if I could use node or something like that and then have a way to import js dependencies in django templates. I've been using htmx and alpine js to sprinkle some…

You can use npm or similar to download and install packages, then link them in your template. Just need to get them into the right folder or perhaps link them.

Re: Django 4.0 release candidate 1 released

#118
post #5

Last week I was trying develop a quick prototype, and instead of setting up a C# project, I tried Django. At first, everything seemed super easy, but later I hit so many road-blocks that I had to give up (For example defining a self-referential m2m relationship with a custom join table, and getting it working on the admin site). Don't people really have such problems with it? It really feels like a huge burden when y…

Interestingly, I also considered doing a recent prototype in C#, but opted to try Django. I didn't hit any roadblocks like this though, overall the experience was pretty nice. The fact that the Django admin site allows you to get instant CRUD functionality from your models with almost zero effort is something I've not seen in other web frameworks (maybe nest.js gets close, but I'd love to see a .NET equivalent to the…

I had the same impression when I tried it a few years ago (also coming from a .NET background).

I never got the chance to use it professionally so I didn’t get the “fully under control” feeling I get when working with .NET, thus never had the confidence to push for it in my company/clients out of fear of not being able to fix whatever went wrong.

Kind of regretting not making the switch back then, but well, nowadays .NET is good enough. Never managed to squeeze as much productivity as I did with those small college projects back then.

Re: Django 4.0 release candidate 1 released

#119
post #5

Last week I was trying develop a quick prototype, and instead of setting up a C# project, I tried Django. At first, everything seemed super easy, but later I hit so many road-blocks that I had to give up (For example defining a self-referential m2m relationship with a custom join table, and getting it working on the admin site). Don't people really have such problems with it? It really feels like a huge burden when y…

OT, but how do you feel C# (w/ ASP and EF, I suppose?) stacks up in productivity and TTM? What's the kind of problem you run into where you start feeling like you're not working on the domain but on side details?

There’s this enterprise mindset surrounding .NET where it feels like you need a lot of boilerplate to do anything, all for the sake of testability. I think I just dislike working with interfaces.

Re: Django 4.0 release candidate 1 released

#120
post #5

Last week I was trying develop a quick prototype, and instead of setting up a C# project, I tried Django. At first, everything seemed super easy, but later I hit so many road-blocks that I had to give up (For example defining a self-referential m2m relationship with a custom join table, and getting it working on the admin site). Don't people really have such problems with it? It really feels like a huge burden when y…

That use case has been easily discovered in the docs for several years at least

Could you please point to me where? Custom join table, check. Self-referencing m2m, check. Setting up admin for it?
Post reply on HN