News for hackers. Stuff that matters.
Re:Django 5.0 Is Released by jmduke on Monday December 04, 2023 @11:20AM (#38519158)
My app is a Django backend and a Vue frontend. There are large swathes of Django that I ignore, but to me the core of Django — its ORM, routing and middleware system, and admin interface — are worth their weight in gold. The migration from DRF to Django-Ninja (which is, roughly, FastAPI + Django) has also been a great improvement in terms of productivity and performance.

Not a lot of whizbang features in 5.0, but GeneratedField looks like a very nice addition, and reason enough to migrate.

Re:Django 5.0 Is Released by jim180 on Monday December 04, 2023 @11:43AM (#38519521)
Coming from iOS/macOS background, I've kinda enjoyed Django with its all time classics (forms, templates, etc.) + HTMX.

Admin interface was extremely helpful, when we are trying to validate business idea.

Re:Django 5.0 Is Released by amir_karbasi on Monday December 04, 2023 @12:05PM (#38519838)
How was the effort to migrate from DRF to Django-Ninja? I saw Django-Ninja mentioned in another post and am thinking of switching one of my projects over from DRF. After skimming their documentation, it looks very pleasant and simple and perfect for my use case.
Re:Django 5.0 Is Released by jmduke on Monday December 04, 2023 @12:08PM (#38519884)
Going from 0 → 1 migrated route was "medium difficulty", I'd say — there was a non-trivial amount of scaffolding I had to build out around auth, error codes, and so on, and django-ninja's docs are still a little lackluster when it comes to edge cases.

Once I had that one migrated route, though, the rest were very simple. (And I am very happy with the migration overall!)

Re:Django 5.0 Is Released by crucialfelix on Monday December 04, 2023 @04:22PM (#38523282)
I've had that on my list to try out for a while now. FastAPI is a joy, having generated OpenAPI is a must, so Ninja sounds good.

I've had quite enough of DRF's tower of mixins and rails like magic. It always sucks up development time and fails too easily.

Re:Django 5.0 Is Released by sprainedankles on Monday December 04, 2023 @11:32AM (#38519347)
Any resources/examples you'd recommend for a Vue frontend w/django? I've been pretty firmly in backend land for a while and would to experiment with the other half of the puzzle!
Re:Django 5.0 Is Released by jmduke on Monday December 04, 2023 @11:43AM (#38519518)
I'll preface all of this with a couple esoteric design goals that I had in mind:

1. I actually _want_ an SPA. You might not need an SPA, if you don't need one then Vue/React/etc are overkill, etc.

2. I want to power as much of the SPA as I can using the same REST API as my core product, both for dogfooding reasons and for consolidation. Many people might argue that this is a bad idea.

---

With that in mind, some specific packages that I highly recommend:

1. Django-vite (https://github.com/MrBin99/django-vite). This makes it very easy to serve an SPA from the actual django response/request model

2. Some sort of way to get type information (if you're using TypeScript) into the frontend. I use a frankensteined system of the OpenAPI spec that django-ninja generates + openapi-typescript (https://github.com/drwpow/openapi-typescript). This means when I add, say, a new field to a response in Django, I immediately get typechecking for it in Vue — which has been _tremendously_ useful.

3. Django-typescript-routes (a package I extracted and open-sourced!: https://github.com/buttondown-email/django-typescript-routes) which gives your front-end routing information based on the Django router.

Re:Django 5.0 Is Released by zelphirkalt on Monday December 04, 2023 @01:37PM (#38521140)
If you really need VueJs in the frontend, consider, that you can simple serve the VueJs on any page where it is actually needed. VueJs does not necessarily mean you must create a SPA. VueJs can be delivered like any other script and this is often the easiest way without having to commit to build a full blown SPA.
Re:Django 5.0 Is Released by malux85 on Monday December 04, 2023 @11:27AM (#38519262)
Mine too - Vue and django, and the django rest framework, it’s super productive - no writing all the crud views manually for the hundreds of models I have, the django admin interface is very helpful like you say, and backend is running (a very highly customized) django celery mix,

Django + REST framework takes a little more to learn than something like FastAPI, but once you understand how all the middleware, permission and query classes work, you can be hyper productive

Re:Django 5.0 Is Released by collyw on Monday December 04, 2023 @01:04PM (#38520662)
Agreed, the admin makes development so much easier, being able to easily enter and view your data.
Re:Django 5.0 Is Released by cdcarter on Monday December 04, 2023 @01:23PM (#38520926)
GeneratedField looks interesting, but I'm not _really_ sure what gains I get over just calling annotate() on my queryset with some computed fields. At least on the backends where the computed GeneratedField isn't stored.
Re:Django 5.0 Is Released by radus on Monday December 04, 2023 @01:32PM (#38521072)
It's easier to re-use if you need the same generated field in multiple places.
Re:Django 5.0 Is Released by cdcarter on Monday December 04, 2023 @02:06PM (#38521589)
I've been in the habit of replacing the default manager for my model with one with an annotated query set. that way, any Model.objects.all() call will have the computed fields.

I find this pretty easy to get used to and re-use. though I do admit I like them defined as actual model-fields with verbose names etc...

Re:Django 5.0 Is Released by OJFord on Monday December 04, 2023 @06:20PM (#38524635)
It's a generated column in the database, vs. annotate is just a python alias for something you're selecting in the query.
Re:Django 5.0 Is Released by tmnvix on Monday December 04, 2023 @10:05PM (#38526595)
Actually having the derived data in the database would be helpful for simplifying something like a website search implementation. I know I could have used it last month!