Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Playing Nice with Django and React

Jacob Cook
November 19, 2017

Playing Nice with Django and React

For a web developer that's used to using Python frameworks like Django or Flask, getting into the world of frontend web development using modern JavaScript isn't always easy. For instance, there is no immediate solution to making new single-page application (SPA) frameworks work well with Django's rendering architecture, especially if you just want to make something simple. This talk will explore the differences between how Django renders web pages and how these JS frameworks expect you to do it, and how to marry the two approaches without reinventing the wheel (or using a heavy library that makes customization difficult). We will look in detail at a few of these concepts, then walk through a fun demo that shows just how efficient and developer-friendly this pattern can be.

This talk is primarily aimed at beginners to frontend web development who may have been around the block with Django once or twice but are not fully on board with the concepts behind the modern JavaScript stack or with React. Those who come from the world of frontend web development and who are new to Django or Flask may also find this talk interesting.

Jacob Cook

November 19, 2017
Tweet

More Decks by Jacob Cook

Other Decks in Programming

Transcript

  1. fullstack n. 1 computing (usually as modifier) The entirety of

    a computer system or application, comprising both the front end and the back end. @peakwinter #PyConCA2017 Source: Oxford Living Dictionary
  2. fullstack n. 2 “We want to hire you to work

    on all parts of the stack because we cannot afford specialized engineers for the different technical stack pieces and feel it's better to start the stack being sub-par instead of having expertise in each stack layer.” Source: SVD @peakwinter #PyConCA2017
  3. Just Enough JavaScript™ 1. Pack it up, pack it in,

    let me begin 2. Render data as hidden JSON 3. For every page, a component 4. ??? 5. Profit @peakwinter #PyConCA2017
  4. @peakwinter #PyConCA2017 mysite/ ├── components/ │ ├── add.jsx │ └──

    list.jsx ├── assets/ │ ├── bundles/ │ └── index.js ├── templates/ │ ├── add.html │ └── list.html ├── models.py ├── views.py └── webpack.config.js
  5. @peakwinter #PyConCA2017 Webpack config: * Entry: ./assets/index * Output: ./assets/bundles/

    * Module loaders: test for *.jsx, use babel-loader ./node_modules/.bin/webpack \ --config webpack.config.js \ --watch