Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Django is awesome, but I wish there was an easy way to use modern web frameworks with it.

A lot of times it's either through Nextjs/Nuxtjs + Django as an API or complex bundling process which requires a file where you register bundle versions/manifests then another build process which embeds them into template

both are so complex





Django is a modern web framework. It simply doesn't follow the hype around JS SPAs. However, if you really want to, you can of course still render static content + serve a JS framework like Vue to the client, and then have dynamic widgets rendered on the client side.

If you want to build an SPA anyway, then Django is not the right framework to start with though.


I use Django + DRF for SPA. SPA bundle is served from an nginx container, but I don't see any problem building it into the django image either.

What is the right framework for building SPAs?


Probably one, whose basic idea is to make an SPA. Django has all the tools for making a multi page website/application, which you are then not using. There is probably a framework that is based on the idea of making an SPA and that doesn't include the other stuff.

its not only about SPA vs non-SPA.

For example, there is a nice component library, shadcn, of course you can somehow embed it into the project, but to use it productively, you must have a bundler, which is outside of Django ecosystem.

Also, if you take a look at AI generated content, a lot of them are optimized for outputting JS for frontend, try embedding it in Django project, its non-trivial


Have you tried Django with Inertia.js?

https://inertiajs.com/


Django + AlpineJS + HTMX is pretty nice.

That's just for the HTML content though. What if you want to add some non-trivial Javascript or generated CSS? Or maybe you want to integrate a frontend tool like Storybook[0] even if your HTML is rendered server-side? Maybe add some tests for your frontend code? There is much more between raw hand-rolled HTML/CSS/JS and a full-blown SPA.

At my day job we use Django with HTMX and Alpine, but we also generate the custom CSS from Pico[1] and use JinjaX[2] to define server-side components which we then render in Storybook. We use Vue as our bundler to compile the JS and CSS as well as to run Storybook. The project has to live in both the Python ecosystem and the Node.js ecosystem.

Even with just HTMX and Alpine you might want to compile a custom version of those with certain plugins, or you might want to load them as libraries in your own scripts.

[0] https://storybook.js.org/ [1] https://picocss.com/ [2] https://jinjax.scaletti.dev/


Especially with template partials now in the core of Django 6.

Yes the API process is very complex and then you have to have a team with proficiency in two parallel sets of web technologies -- python vs javascript. That said, the fact that you can go that route means that Django can be a good pick for early-stage projects where you don't need a frontend framework, because there's the optionality to add it later if your project really requires it.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: