News for hackers. Stuff that matters.
Re:Django 4.2 Released by bbbbzzz1 on Monday April 03, 2023 @03:41PM (#35430101)
I feel like lately js (and more importantly typescript) frameworks have been more popular. If someone were to start a new project today, how does Django standup to the current offerings?
Re:Django 4.2 Released by winrid on Monday April 03, 2023 @03:57PM (#35430352)
I just got into Django after working with Node/Java for years. It's honestly depressing once I realized I have spent so much time building CRUD stuff that would have taken 10x less time with Django.

I haven't built SPAs yet, but I'm looking into trying Unicorn: https://www.django-unicorn.com/

Re:Django 4.2 Released by surfingdino on Monday April 03, 2023 @03:51PM (#35430267)
Django's hidden powers are its highly customisable admin UI and ORM. Add to it Django REST framework and you have a solid backend for a wide category of web apps, from the old pre-XMLHttpRequest apps to SPAs. Flask or FastAPI get you going fast, but you quickly realise that you have to write a lot of the code that comes with Django for free.
Re:Django 4.2 Released by hooverd on Monday April 03, 2023 @03:58PM (#35430363)
I personally prefer Django Ninja over DRF for APIs, it's all the good parts of FastAPI mixed with Django.
Re:Django 4.2 Released by zach_garwood on Monday April 03, 2023 @05:29PM (#35431548)
Honestly, I think the generic and model views are way more impressive than the ORM or the admin. They take away all of the boilerplate usually associated with CRUD apps.
Re:Django 4.2 Released by luxcem on Tuesday April 04, 2023 @05:00AM (#35436937)
I've used them for quite a while but came back to the old function views. The Generic Views are a mess to understand, the hierarchy tree gets so complicated. See for example : https://ccbv.co.uk/projects/Django/4.1/django.views.generic.... there are 9 classes in the inheritance tree. For every slight change from the default behavior you need to research the documentation, find which method to override…

In the end I have to write a bit more of boilerplate each time (and with tools like copilot it's a non-issue) but it's 10x faster to understand what a view does and how when reading code.

Re:Django 4.2 Released by Nextgrid on Tuesday April 04, 2023 @06:51PM (#35446915)
> For every slight change from the default behavior you need to research the documentation, find which method to override…

I just use an IDE which allows me to Ctrl+Click into any symbol and see its implementation and underlying classes (and do so recursively if needed). That saves me from having to lookup the documentation all the time.

Re:Django 4.2 Released by petr25102018 on Monday April 03, 2023 @04:24PM (#35430749)
It is different. JS is popular because people who write SPAs also want to write backends in the same language.

What I really like about Django and Python ecosystem in general is the kind of stability that it doesn't move too fast and break things, which happens in JS land too often. And Python is a nicer language of the two, for me at least.

But at the end of the day, you can combine both. I work for Baserow now and we combine Nuxt + Django. You can also simplify it to Vue/React + Vite + serve it with Django, use cookies-base auth etc.

Re:Django 4.2 Released by asciii on Monday April 03, 2023 @03:57PM (#35430353)
It just works in most cases. It is nice to be within Python's ecosystem as well.

Overall, I've found it great for prototyping up something really quickly. I think this is where the "batteries-included" helps a lot

Re:Django 4.2 Released by matsemann on Monday April 03, 2023 @04:02PM (#35430425)
I feel the opposite. Django is fine, but python ecosystem is the big problem. The lack of true multi threading means for even the simplest of apps you quickly need to have multiple deployments, celery workers etc to handle different kinds of workloads.
Re:Django 4.2 Released by winrid on Monday April 03, 2023 @06:34PM (#35432258)
You could argue having workers run single threaded code is a lot easier than multithreading, depending on your hiring pool.
Re:Django 4.2 Released by crop_rotation on Monday April 03, 2023 @03:44PM (#35430152)
If you use a RDBMS then Django is a very good choice whether you use SPA or not.
Re:Django 4.2 Released by bshipp on Monday April 03, 2023 @04:19PM (#35430678)
I agree, although I really wish Django and SqlAlchemy would have evolved similar methods. My struggle is flipping between projects that use or the other and tripping over the syntax.
Re:Django 4.2 Released by znpy on Monday April 03, 2023 @03:46PM (#35430165)
It’s boring, well documented, has a ton of modules, extensible, solid, robust, reliable, trustworthy.

I’d pick it for these reasons.

Re:Django 4.2 Released by ye-olde-sysrq on Monday April 03, 2023 @05:08PM (#35431313)
Personally I feel like I've unlocked a superpower with this one trick (using rails, but this applies equally to django and similar "old" page-load-based frameworks)

1. build your app in the normal, old way. just doing SSR for showing and editing boring content is so much faster than building it in react.

2. I have a tiny scrap of JS that digs through elements on the page, and if they have a class, creates a React root there and passes in some params. I then wrapped generating those replace-me-with-a-react-root elements in a Rails helper function.

(2 is my "fine I'll do it myself" after Rails 7's new js stuff broke react-rails for me.)

This might be colored by me being a backend dev and data engineer type of person and I have terrifically little patience for writing javascript. But pages where I've followed this "SSR + some React doodads for when you really need special sauce" pattern end up so much easier and faster to write than cramming it all into a huge SPA.

I'm sure if you're building something deeply fancy then doing it all in React makes sense, but I find there's really only a couple pages that actually do end up being 100% react and the rest end up fine just having a text field here or there or a little widget thingy being the React components and the rest just being SSR.

I'm sure this doesn't scale if you're google or something either but even on my most complicated pages this still loads visibly faster than many other sites I use.

Re:Django 4.2 Released by jononomo on Monday April 03, 2023 @09:00PM (#35433610)
I believe this is the way React was originally supposed to be used -- just for a little widgets here and there, not for the entire page/application.
Re:Django 4.2 Released by anyfactor on Monday April 03, 2023 @05:09PM (#35431329)
I don't do proper web dev work and tried Django ages ago. So, this is a very narrow opinion. I use mainly flask and firebase these days as a indiehacker.

I don't think currenlty there are any solid alternatives beyond Nestjs+Typescript, ruby on rails and laravel. The sentimemt of their community is that these frameworks are built for web development in mind. While I think for Python based web framework like Django the sentiment is that you are using Python already and here is a web framework written in Python. If you look at some of the Rust based web frameworks you will understand what I am saying. The merit of the framework is the language it was written in. This makes hiring web developers difficult as most candidates will be Python Developer who knows Django and not web developers who knows Python. There are very few people who learned Python to use Django. But everyone learned javascript to use nodejs, or ruby to use ruby on rails.

If I am writing enterprise level where Python is used I will pick one of those 3 frameworks and use a Python based API framework like DRF or FastAPI for building internal APIs.

Re:Django 4.2 Released by winrid on Monday April 03, 2023 @06:35PM (#35432279)
Python is literally the easiest language to learn. Any web dev can pick it up, and Django is much more productive than NestJS. Rails and Laravel are nice options too. No Rust or Java options come close.
Re:Django 4.2 Released by Danjoe4 on Monday April 03, 2023 @10:42PM (#35434308)
The admin page, DB integration, robust feature set, and insanely good documentation make Django a slam dunk for me. I do understand your sentiment though and for any website that requires a lot of interactivity you need a JS oriented framework like NextJS.

If I need a database and interactivity I pair NextJS with Django Restapi.

Re:Django 4.2 Released by toyg on Tuesday April 04, 2023 @12:46AM (#35435194)
> everyone learned javascript to use nodejs

Wut? It's more a case of "everyone learned javascript to do button rollovers in the browser, and then nodejs allowed them to do more".