ericpalakovichcarr / drf-react-redux

This repository shows how to use Django, Django Rest Framework, React, and Redux together.
MIT License
81 stars 18 forks source link

Redux DevTools + Django todomvc example

This repository shows how to use Django, Django Rest Framework, React, and Redux together. It also utilizes hot reloading via webpack and redux dev tools to enable time traveling state.

That said, it's a little slapped together. It all works, but this ain't production level code. But feel free to use this to get a feel of how you can fit these things together.

Also, this is based off of Dan Abromov's todomvc example in https://github.com/gaearon/redux-devtools. You can find that here:

https://github.com/gaearon/redux-devtools/tree/master/examples/todomvc

Running Example

First, clone the project:

git clone https://github.com/bigsassy/drf-react-redux.git && cd drf-react-redux

Next, create a virtualenv for your repository:

virtualenv env && source env/bin/activate && pip install -r requirements.txt

Now go into the Django project directory.

cd todomvc

This is our django project, which was created with django-admin startproject by myself when creating this example repository. I've changed a few things after running that command:

Anyway, now go ahead and install the javascript dependencies in the root folder:

npm install

Then create the database for the Django project, and create a super user:

./manage.py migrate && ./manage.py createsuperuser

Now open this directory in a second terminal, and turn on your virtualenv by running source ../env/bin/activate. Run the first command in one terminal, and the second command in the other terminal:

npm start
./manage.py runserver

Finally, login to your site via the admin: http://localhost:8000/admin

After you're logged in, you'll be able to use the Todo app and browse the API: