Hello, If I use Django for the backend and React js for frontend, is it possible to host it on pythonwhere?
Hello, If I use Django for the backend and React js for frontend, is it possible to host it on pythonwhere?
Sure, that should work fine -- it's actually the setup we use ourselves. Specifically we use Django Rest Framework for the server side (and we like it a lot) but regular Django should work fine too.
If you want to compile your React JSX code into regular JavaScript on PythonAnywhere, you'll probably want to upgrade the installed Node package -- this help page explains how.
Ok. Thanks.
hi, can we do this in free account
Yes, you can.
when i ran this, npm install -g create-react-app. i got
npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR! { Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/lib/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
**I was able to sort it out **
oh okay thanks for letting us know!
Hello, Is "npm" works normally in Pythonanywhere the way I can use it on my local machine ( development mode), or do we need to add any packages? I want to install TailwindCSS locally in the env of Pythonanywhere. Your help is much appreciated! Any example would be nice to have for reference.
Thank you
NPM is installed and works fine; if you're doing anything Node-related, though, we do recommend that you use NVM to get the most recent version that you can; this help page has the details.
Hi, I am struggling to use react app with django.
So, django project works fine as expected.
Per instructions here (https://help.pythonanywhere.com/pages/Node) , I installed nvm and chose default version v14.20.0 (LTS)
Now, I want to create a simple react UI inside by django project directory via
npx create-react-app my_ui
And get error:
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! code Unknown system error -122
npm ERR! syscall close
npm ERR! errno -122
npm ERR! Unknown system error -122: Unknown system error -122, close
npm ERR! code Unknown system error -122
...
Aborting installation.
npm install --no-audit --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
Same errors can be received via simple:
npm install --no-audit --save --save-exact --loglevel error react-scripts
What am I doing wrong? Please help :(
Could you try with a newer version of node?
Per the https://www.pythonanywhere.com/forums/topic/27789, nvm is already installed on the system.
resolves the issue and create-react-app works.
I am still curious why the standard LTS installation and instructions discussed in the https://help.pythonanywhere.com/pages/Node do not work
Hi, is there by chance a sample application of django + react?
I really wanted to see the settings.py and whatever other things that need to be setup to enable a react frontend with django serving the rest endpoints?
Thank you
No, we do not have a sample of that. React is just static files so, as long as you serve them correctly, it will just work. Search for "static" in our help pages and you'll find many pages to help with serving static pages.
Thank, it is fine and I will try to set it up myself. What I did find on one of the pythonanywhere posts was: <pre> note that that will not work automatically on PythonAnywhere, since it is not possible to run a development server on PythonAnywhere, you'd need to build React files again instead </pre>
Is that information correct? Coding complex react ui without auto-reloading functionality is a no-go for me
It is correct. You can deploy React to PythonAnywhere but it's not really js development platform.