3 ms·
This list is impressive, but a lot of these packages are used to generate HTML which is then not usable for SPA. Do any of you have a similar list for SPA orie
by polote 9y ago
This list is impressive, but a lot of these packages are used to generate HTML which is then not usable for SPA.
Do any of you have a similar list for SPA oriented projects ?
- y4mi 9y agohonestly? use nodejs for that. django can still give you the backend through DRF or django-graphene, but frontend for SPA is (in my opinion as a dabbler that hates js) way better with node. take markojs as an example. creating an app with marko-cli gets you a simple demo application with 3 webpages and you're ready to go. you can use concise html syntax (way cleaner and i'm still astonished that there is no similie for django). the stateful components syntax is way cleaner. this is especially true for for/if/whatever tags like it or not js is the language of the web. django is still wonderful if you're not focused on SPA applications though. And this includes websites with contents which update through ajax calls.
- drdaeman 9y agoI believe it works like this: 1. Django for the backend. Nothing but an API (DRF, GraphQL, some custom views or whatever one fancies) and - if server-side rendering is not necessary - a catch-all view that spits out HTML file with the JS bundle. It either doesn't know anything about the frontend, or, possibly, can read Webpack stats file (using django-webpack-loader) to figure out correct bundle filename. It may also run Django Admin Interface, independently from the SPA - as an almost independent "back office" site. 2. JS/TS/Elm/whatever and, probably, Webpack for the frontend/SPA itself. If server-side rendering is desirable, a Node-based server. All it knows about the backend is the API contract. Trying to somehow embed JS into Python/Django is not easy, error-prone, and I just don't see any benefits of doing so. 3. A router that sends requests to the correct piece. I've always used a simplest-possible nginx setup with location /api/ { ... } and location / { ... }.
- lastofus 9y agoThe 2 that come to mind are DRF and django-webpack-loader. The webpack loader is great if you use webpack, and want to use the Django template language to render your index.html. Sometimes server side rendering of initial data is nicer than having to send all initial data down w/ AJAX calls.