Anyone have any success/tips using webpack with django collectstatic?
Yeah, it's no different to any other setup. Just have webpack dump the assets into a static folder somewhere ready for collectstatic.
Django React/Redux Base Project
31–40 of 79 posts
Re: Django React/Redux Base Project
#32So for people who think they need Redux, first read "You Might Not Need Redux" [0] by Dan Abramov himself, creator of Redux. Then also I would recommend MobX [1] over Redux, it's easier to get started and in my opinion easier and better in general. [0] https://medium.com/@dan_abramov/you-might-not-need-redux-be4... [1] https://github.com/mobxjs/mobx
Things like this (from the docs) make me nervous:
const TodoView = observer(({todo}) =>
todo.finished = !todo.finished}
/>{todo.title}
)
TodoView is a dumb component that operates simple data passed via props, but now it needs to know that it's an observer and presumably rely on some facet of MobX to work?Re: Django React/Redux Base Project
#33Django + React is an awesome combination that I recommend taking a look at. This repo is a good starting point but you can probably get rid of half of the dependencies if you aren't working on a team of developers. I am currently using Django + React on a personal project and took a slightly different route, no pun intended. Rather than using react router, as I never really liked client side routing, I use Django vie…
The nice thing about react router and client side routing is you can have a very clean separation from your backend data model and your actual UI/website.
I would agree that react router is like a 1000 pound javascript routing gorilla.
Re: Django React/Redux Base Project
#34I feel like the best way to do this is to just use cornice or DRF then use js scaffolding that is completely unaware of your backend. No need to join them at the hip like this, except maybe for the token based auth?
I've tried working with tools like Djangular and whatnot, and no matter how many times I've tried working within that ecosystem, I've always had better results, cleaner and simpler code by keeping the UI and Backend completely separate.
Re: Django React/Redux Base Project
#35Re: Django React/Redux Base Project
#36Earlier quoted context omitted.
is there a better way to get server side rendering rather than a whole dependency on node for a django project?
If your project is small enough you can scrape it and generate all pages. You need a server only in development but then you can host it statically (and for free, e.g. on github). Check out hasgluten.com for an example, code here (pretty old version of react though): https://github.com/hasgluten/hasgluten
The case I was interested in is where you'd like to have Django server-side-render the first request based on url, and then have react handle the rest via react-router and apis ala django-rest-framework.
As a backend dev who got by with jquery soup and 0 frontend build tools before (use django bundling tools), even starting to approach the React ecosystem is a little daunting.
Re: Django React/Redux Base Project
#37Earlier quoted context omitted.
is there a better way to get server side rendering rather than a whole dependency on node for a django project?
Doesn't avoid the node dependency, but try https://github.com/airbnb/hypernova Honestly the node dep isn't so bad. Just think of it as a template render running on another process.
Deployed some swap and once thumbnail caches are warm we're fine, but, adding node as an additional dependency just seems overkill. python-react seems like a good fit.[0]
[0] https://github.com/markfinger/python-react
edit: s/React-python/python-react/g
Re: Django React/Redux Base Project
#38And me thinking it was a peaceful software project, without any soldering or soldiering...
Re: Django React/Redux Base Project
#39"We build on the solders of giants." And me thinking it was a peaceful software project, without any soldering or soldiering...
Re: Django React/Redux Base Project
#40So for people who think they need Redux, first read "You Might Not Need Redux" [0] by Dan Abramov himself, creator of Redux. Then also I would recommend MobX [1] over Redux, it's easier to get started and in my opinion easier and better in general. [0] https://medium.com/@dan_abramov/you-might-not-need-redux-be4... [1] https://github.com/mobxjs/mobx