ponynote | Repository for Modern Django '' tutorial | Learning library
kandi X-RAY | ponynote Summary
kandi X-RAY | ponynote Summary
Modern note taking application with Django and ReactJS. This code repository is for my tutorial blog post: Modern Django.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ponynote
ponynote Key Features
ponynote Examples and Code Snippets
Community Discussions
Trending Discussions on ponynote
QUESTION
I'm following this tutorial:
http://v1k45.com/blog/modern-django-part-1-setting-up-django-and-react/
The tutorial describes how to set up a Django/React app using webpack.
Everything works fine on my development machine but I have problems with the static files on a remote server (Ubuntu 16.04.4).
These are my questions:
1) Why is my development version looking for the static files in localhost?
2) If I use Nginx/Passenger to serve the production version, the static files are not loaded in the browser even though the links look correct. Why is this?
Edit: I think I've found the answer to setting up Passenger. Even though the wsgi.py loads the application, you need to tell Nginx where the static files are located. My working /etc/nginx/sites-enabled/ponynote.conf:
...ANSWER
Answered 2018-Dec-14 at 15:42If the scripts don't load and you see the HTML of your homepage when you visit the script's URL in your browser, this means either your links are wrong or Nginx isn't serving up the files. (As there is no file at the URL, Nginx gives you the home page instead.) What I didn't realise at first is that although Nginx by default serves the Django app, it doesn't serve any static files that aren't in the 'public' folder, so doesn't serve the build output.
It also seems that create-react-app has changed since the tutorial I followed was written; you don't seem to need to do any webpack config now.
And finally you need to put the frontend build output somewhere the Django app will find it.
A newer tutorial led me to an approach which is working on the production server: https://medium.com/alpha-coder/heres-a-dead-simple-react-django-setup-for-your-next-project-c0b0036663c6. I chose to keep frontend in its own folder, and I'm using Nginx/Passenger, so I made a couple of changes.
Here's how I set it up.
1) After setting up your Django project, create a React app in the project root folder with:
QUESTION
I'm trying to deploy a web app built with Django/Redux/React/Webpack on a Digital Ocean droplet. I'm using Phusion Passenger and Nginx on the deployment server.
I used create-react-app to build a Django app which has a frontend that uses React/Redux, and a backend api that uses django-rest-framework. I built the frontend using npm run build
.
The Django app is configured to look in the frontend/build folder for its files and everything works as expected, including authentication. It's based on this tutorial: http://v1k45.com/blog/modern-django-part-1-setting-up-django-and-react/
In settings.py:
...ANSWER
Answered 2018-Dec-06 at 19:18Create-react-app has a fairly opinionated setup for local and production environments.
Locally, running npm start
will run a webpack-dev-server, which you would typically access on port 3000. It runs a local nodejs web server to serve the files. You can route requests to your local Django server via the proxy setting.
It's worth noting that at this point there is little or no connection between your React app and Django. If you use the proxy setting, the only thing connecting the two apps is the routing of any requests not handled by your React app to your Django app via the port.
By default in create-react-app (and as noted in the tutorial you mentioned you are following) in production you would run npm run build
which will process your create-react-app files into static JS and CSS files, which are then accessed in Django like static files any other Django app.
One thing Django is missing in order to access the static files is a way to know what files are generated when running npm run build
. Running a build will typically result in files output like this:
QUESTION
I am starting to learn some react, and trying to learn how to combine ReactJS and Django. I am currently following the proposed tutorial here
After setting up the django urls, and installing django-webpack-loader
, I am stuck with the following error when running the django server:
ANSWER
Answered 2018-May-23 at 23:18You must add webpack_loader
to your INSTALLED_APPS
as described in the tutorial:
Then in the project settings.py (
ponynote.settings
) addwebpack_loader
inINSTALLED_APPS
list and add the following [...]`
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ponynote
Clone it
$ pip install -r requirements.txt
$ cd ponynote/frontend
$ npm install
$ npm run start
$ python manage.py runserver
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page