/django-reactjs-boilerplate

An example how you can use ReactJS with your Django project.

Primary LanguageJavaScript

Django ReactJS Boilerplate

This repository was used for my talk at the Python User Group Singapore March Meetup 2016

I gave the talk a second time at a PyLadies meetup and it was recorded by Engineers.SG.

The goal is to show how you can use ReactJS in your existing Django apps today.

This is far from perfect. This approach is not universal, so it only works for components that don't need to be indexed by Google (and thus need to be pre-rendered on your server). However, the highly interactive stuff usually happens behind a login form anyways (think Trello: They have a few static pages to advertise their product but the real app is behind a login).

Credit where credit is due:

This awesome blog post by Owais Lone finally pushed me into the right direction: http://owaislone.org/blog/webpack-plus-reactjs-and-django/

Try this on your machine

You can clone this repository, install all dependencies and try it in your browser quite easily:

git clone https://github.com/mbrochh/django-reactjs-boilerplate.git
cd django-reactjs-boilerplate/django
mkvirtualenv djreact
pip install -r requirements.txt
npm install
./manage.py migrate
./manage.py runserver

# in another terminal:
node server.js

Follow my train of thought

If you want to learn how I came up with this repository, you can follow my train of thought by going into all those branches.

The README.md in each branch will tell you what you need to do in order to get to a state that is (hopefully) equal to that branch. If anything doesn't work, just compare your files to the ones in the branch. If your really can't figure it out, just checkout that branch and run it locally and play with it for a while, then move on to the next branch.

Start with Step 1: Create your Django project