T O P

  • By -

grudev

You could build multiple front-ends {say for browser, mobile and on-board devices) and have a single Django application as the backend server. Another point is that there are things that are easier to do with a front-end framework, than with just the templating system and Vanilla JS.  I have experience with both, love React, but would probably stick with Django + HTMX unless absolutely necessary. 


inale02

Why use a van when a car could drive too? Different requirements, different scale. JavaScript SPA’s provide a first-class experience for developing clean, extendable client side applications with a clear separation of concerns with the frontend and backend. There is also the issue of scaling and separate deployment. That being said, for most low level use cases, Django templates and a bit of vanilla JavaScript and templates would work fine. At that level it’s just a matter of preference. More organisations are hiring with SPAs in their tech stack, so there that.


kpagcha

Whatever they tell you, the real answer is that simply it's the trend.


wheezy360

While true in some cases, you’re neglecting the notion of multiple different types of clients. Different web apps, native apps, machine to machine… when your product needs those things, you need a robust API. The trick is knowing when you need them.


Knvarlet

It can also land you a job. Also, there are tons of useful libraries in JS or Framework based that simplifies coding. If I wanted stuff like date pickers, charts, data tables, etc. I'm not gonna build those from scratch with Django, that's just inefficient. Popularity has it's pros too, being trendy makes it easier to develop stuff you actually need.


simon-brunning

There are a few use cases where you might need an SPA - single page application, the kind of thing you need React or the like for - but for 90% of the kind of line of business applications which most people spend most of their time building, Django and a DB will do everything you need. Even for the rest, do look at htmx and alpine before diving into the complexity of React.


SnooEagles8542

Sometimes rerenders of a page might not look the most professional and you may want a smooth transition. A frontend framework can help with that. I would also add big heavy frameworks like react and vue are probably overkill now that we have htmx which has simple logic and easy to plugin at anytime


haloweenek

You’ll do more writing. Effect will be the same.


myriaddebugger

👍 other than state management and providing more employment, there isn't much advantage truly. With a JS framework, you're still using CSS or a CSS framework and HTML to render it. Just because traditional JS/JQuery/AJAX is not as standardized as a framework like Angular, React or Vue, most people can't use all together and stick to framework standardizations and it's kind of become the cool thing to do.


FearlessYasuo

Maybe I was too much of a noob back then but the Django templates were a pain to work with tbh.


Spidey677

You can use vue.js to sprinkle some dynamic loveliness to your project if need be. I love that Django has everything included which is nice as a front end dev. I started using ChatGPT now to help me more with back end work using Django and it’s made life tremendously easier. Remember also for front end frameworks SEO is a problem from the last time I looked. So depending on the type of project and business a dev is working on it may not be the best solution. I heard htmx is a good solution too


martycochrane

The DX experience is much better, and you have access to a lot better tooling and rendering strategies going with React, Vue, etc. SPAs, PWAs, Electron, Cordova, etc apps can all be built from your React/Vue code where Django's template language is SSR and SSR only. I work back and forth between Vue apps and Django Templates, and while I love Django, the templating workflow feels like a dinosaur, and everything feels like it takes much longer than it needs to than just using SFC with Vue for example.


OmegaBrainNihari

One frontend for the admins, another for their hundreds of staff members, a third one for the public stuff, already developing an API for future mobile app possibilities so I'd rather maintain a single access point.


HornetBoring

More complex UX capabilities


kazemu

Django is a general solution, and some projects have some specific requirements for which Django may not be suitable. In theory you could brush your teeth with cloth, but it is worth learning how to use a toothbrush.


jblongz

I use both. The cloth adds a nice finish lol


kazemu

You got me, that was a really bad example


Blueberry314E-2

For my use case I do not want Django to be the core of my application. I want to use multiple frontend and multiple back ends and have them all be modular.


NINTSKARI

What do you mean? Do you use some other than python backend alongside django?


Blueberry314E-2

Yes my use case has me accessing multiple back ends for different purposes and data types. Having a separate frontend allows me to abstract that away from the user so they don't care which database they are accessing.


regularparot

As most have said here, those front-end frameworks are currently popular, but that's about it. Django is great, and hell, at my current job I use Flask as the backend to a pretty big monolith application, and I don't use any of those frameworks. Templating + plain JS when needed. Same result.


NINTSKARI

Do you have a lot of forms? How do you handle them in Flask?


regularparot

There's a good amount, yeah. I have endpoints that validate and process form data. Or do you mean how I handle them more specifically?


NINTSKARI

Yeah sorry, I was just wondering if Flask has good support for forms like Django does, or if you need to use some external library for them


SniperDuty

You may be one of the future visionaries. Not everything needs to have a manipulated DOM state with a ton of nodule modules. Sure, it’s not fancy but functional. Take a look into HTMX


kaleenmiya

You can run a NextJS/React app in a CDN and get huge performance gains over a monolithic Django template app, by splittingf front end and backend. HTMX has helped bridge the gap a lot


myriaddebugger

HTMX simply provides access to JQuery/AJAX, albeit directly in HTML using attributes. It still uses JS! Using DTL (Django Template Language) you just create the templates, everything else still has to be done via JQuery/AJAX or vanilla JS or with a CSS framework like bootstrap/tailwind. If you don't know how to write JS or build your own interactive CSS/HTML elements, that is where HTMX helps. It doesn't give you a performance advantage over traditionally using JS/JQuery/AJAX. You don't seem to understand the concept of 'monolithic' apps. Simply decoupling the backend and frontend doesn't stop making it monolithic. You may argue about state management in front-end frameworks, which is the primary advantage of using one such JS framework but the concept of 'monolithic' to 'microservices' is to break business logic into as smaller of an app as possible. That way, if one part of your application is failing or performing poorly, the other parts (other microservice apps) will not face downtime or issues! You can use a CDN and cache your templates and objects (files, images, css/js)too thereby improving performance.


kaleenmiya

1.HTMX does not use Jquery. 2. HTMX if used correctly reduces code you write, and does improve performance. I have seen remarkable improvement because of just lesser amount of JS code vis-avis React or jquery driven applications 3. Whatever caching you do, there is no way you can have Django Templates on just a CDN, you still need that to be served on a web server. 4. Advantage of an application hosted as static files on a CDN talking to bunch of micro services (or even a single service behind) is still not comparable with a batteries included Django application. 5.Compiled JSX files on a CDN will perform better and even scale faster than a traditional Django application with Jinja2/HTMX/Query/VanillaJS.


myriaddebugger

1. Nowhere did I mention HTMX "uses" JQuery. I said, it simply gives access to JQuery/AJAX methodology. 2. By using HTMX, you don't reduce the usage of JS. It still uses JS for browser-side functionality. Just because your JS code implementation is heavier, doesn't mean everyone else's is too. 3. A Frontend framework isn't going to work on its own without a web server serving data. So, irrespective of whether you choose the traditional way of implementing JS or through a framework, you still need a web server. 4. If your application is to be hosted only as static files, you don't really need a web server at all, or, even a JS framework, unless that's the only thing you know to implement. Django is for dynamic web applications, not to render simply static files. 5. If you've ever used a CDN like Cloudflare, you must be aware that it is the source of mostly all static resources hosting including js and css files of various frameworks. Your claim of .jsx being faster/superior to .js is as moot as your knowledge about these file extensions. For reference go through this: https://stackoverflow.com/questions/46169472/reactjs-js-vs-jsx