2 ms·
Project structure organization such as these always struck me as fitting a square peg into a round hole. Django and React/Redux (and other JS frameworks) have d
by senko 9y ago
Project structure organization such as these always struck me as fitting a square peg into a round hole. Django and React/Redux (and other JS frameworks) have different way of organizing the project structure, and if you fit one inside the other (like here django project inside the redux project, or having a django app that holds the entire ui) makes things messy.
My preferred solutions for this is having a layer above, so the structure looks like:
* "backend" (contains typical django project structure, whatever you like)
* "ui" (contains typical frontned project structure, fire-away your webpack templates, it won't affect/care about the backend bits)
* "ansible" / "docker" / ... whatever devops or other stuff may be needed
* "README.md" explaining this and pointing the user to backend or frontend READMEs for more info.
This is cleaner (different parts nicely separated), instantly recognizable to anyone working on one part but totally unfamiliar with the other, and allows you to use whichever scaffolding techniquies you want (eg cookiecutter on the backend, cli tools for react/vue/angular/whatever).
- lfrodrigues 9y agoNot saying it's the best/only approach but it made sense at the time. For example, Sentry does the same: https://github.com/getsentry/sentry/ https://github.com/getsentry/sentry/ Technically in Django you should put all the "static" into a static folder.
- senko 9y agoIndeed, but what Django considers static assets are, with many modern frameworks, build results, not source itself. If you put all the UI bits inside static, you'll either service your JS source files, build config, node_modules and the like, or you'll need to muck around hiding those. If instead you have a separate project diferctory for the UI bits and then just configure it to use the Django's static folder as the output dir (or alternatively, configure Django to to add the UI build folder in STATICFILES_DIRS), you avoid this pain.