Looks at why and how to combine Django and React, making your user interface more modular and easier to work with. Also briefly covers creating APIs, and running everything in Docker.
Who is Rivo? Rivo Laks Python for ~8 yrs, Django for ~6 yrs CTO of Thorgate Thorgate is Estonian web agency / VC Mostly web-based projects, using Django & React
Motivation Django is very good choice for backend dev For frontend though, Javascript cannot be ignored Python is great for glueing together various technologies
Motivation Django is very good choice for backend dev For frontend though, Javascript cannot be ignored Python is great for glueing together various technologies Let's combine the two!
React JS library for building user interfaces Built by Facebook, open-sourced in March 2015 Not a full framework, easy to get started with Brings declarative thinking to JS
Single Page Apps Should we create an SPA? SPAs have steep learning curve React makes it easy to start incrementally Can move to full SPA later (or immediately), if desired
Single Page Apps Should we create an SPA? SPAs have steep learning curve React makes it easy to start incrementally Can move to full SPA later (or immediately), if desired Use your Django expertise, add React where needed
De ne the JS init() function to render the React component into container function init() { const container = document.getElementById('container'); ReactDOM.render(, container); } HelloMessage is a React component.
Using APIs For loading interactive data, create APIs with Django REST framework. Integrates with Django's models and authentication Built-in functionality includes paging, throttling, validation, etc
Using APIs For loading interactive data, create APIs with Django REST framework. Integrates with Django's models and authentication Built-in functionality includes paging, throttling, validation, etc Browsable APIs
Docker 101 Easily run speci c version of Python: docker run -it python:3.6.1 Volumes for persisting data: docker run -it -v $PWD:/app python:3.6.1 Run Jupyter SciPy notebook: docker run -p 8888:8888 -v $PWD:/home/jovyan/work jupyter/scipy-notebook
Docker Compose Docker Compose is “a tool for de ning and running multi-container Docker applications” de ne & control multiple containers at once easier networking among single app's services
Conclusions Don't let Javascript scare you, embrace it You can start using React incrementally Use Django REST framework for APIs Docker helps with env setup