Lightweight Django: Using Rest, Websockets, and Backbone

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

How can you take advantage of the Django framework to integrate complex client-side interactions and real-time features into your web applications? Through a series of rapid application development projects, this hands-on book shows experienced Django developers how to include REST APIs, WebSockets, and client-side MVC frameworks such as Backbone.js into new or existing projects. Learn how to make the most of Django's decoupled design by choosing the components you need to build the lightweight applications you want. Once you finish this book, you'll know how to build single-page applications that respond to interactions in real time. If you're familiar with Python and JavaScript, you're good to go. Learn a lightweight approach for starting a new Django project Break reusable applications into smaller services that communicate with one another Create a static, rapid prototyping site as a scaffold for websites and applications Build a REST API with django-rest-framework Learn how to use Django with the Backbone.js MVC framework Create a single-page web application on top of your REST API Integrate real-time features with WebSockets and the Tornado networking library Use the book's code-driven examples in your own projects

Author(s): Julia Elman; Mark Lavin
Publisher: O'Reilly Media
Year: 2014

Language: English
Pages: 246

Copyright
Table of Contents
Preface
Why This Book?
Who Should Read This Book?
Who Should Not Read This Book?
About the Examples
Organization of This Book
Conventions Used in This Book
How to Contact Us
Acknowledgments
Julia
Mark
Prerequisites
Python
Python Packages
Web Development
JavaScript
Browser Support
Additional Software
Chapter 1. The World’s Smallest Django Project
Hello Django
Creating the View
The URL Patterns
The Settings
Running the Example
Improvements
WSGI Application
Additional Configuration
Reusable Template
Chapter 2. Stateless Web Application
Why Stateless?
Reusable Apps Versus Composable Services
Placeholder Image Server
Views
URL Patterns
Placeholder View
Image Manipulation
Adding Caching
Creating the Home Page View
Adding Static and Template Settings
Home Page Template and CSS
Completed Project
Chapter 3. Building a Static Site Generator
Creating Static Sites with Django
What Is Rapid Prototyping?
Initial Project Layout
File/Folder Scaffolding
Basic Settings
Page Rendering
Creating Our Base Templates
Static Page Generator
Basic Styling
Prototype Layouts and Navigation
Generating Static Content
Settings Configuration
Custom Management Command
Building a Single Page
Serving and Compressing Static Files
Hashing Our CSS and JavaScript Files
Compressing Our Static Files
Generating Dynamic Content
Updating Our Templates
Adding Metadata
Chapter 4. Building a REST API
Django and REST
Scrum Board Data Map
Initial Project Layout
Project Settings
No Django Admin?
Models
Designing the API
Sprint Endpoints
Task and User Endpoints
Connecting to the Router
Linking Resources
Testing Out the API
Using the Browsable API
Adding Filtering
Adding Validations
Using a Python Client
Next Steps
Chapter 5. Client-Side Django with Backbone.js
Brief Overview of Backbone
Setting Up Your Project Files
JavaScript Dependencies
Organization of Your Backbone Application Files
Connecting Backbone to Django
Client-Side Backbone Routing
Creating a Basic Home Page View
Setting Up a Minimal Router
Using _.template from Underscore.js
Building User Authentication
Creating a Session Model
Creating a Login View
Generic Form View
Authenticating Routes
Creating a Header View
Chapter 6. Single-Page Web Application
What Are Single-Page Web Applications?
Discovering the API
Fetching the API
Model Customizations
Collection Customizations
Building Our Home Page
Displaying the Current Sprints
Creating New Sprints
Sprint Detail Page
Rendering the Sprint
Routing the Sprint Detail
Using the Client State
Rendering the Tasks
AddTaskView
CRUD Tasks
Rendering Tasks Within a Sprint
Updating Tasks
Inline Edit Features
Chapter 7. Real-Time Django
HTML5 Real-Time APIs
Websockets
Server-Sent Events
WebRTC
Websockets with Tornado
Introduction to Tornado
Message Subscriptions
Client Communication
Minimal Example
Socket Wrapper
Client Connection
Sending Events from the Client
Handling Events from the Client
Updating Task State
Chapter 8. Communication Between Django and Tornado
Receiving Updates in Tornado
Sending Updates from Django
Handling Updates on the Client
Server Improvements
Robust Subscriptions
Websocket Authentication
Better Updates
Secure Updates
Final Websocket Server
Index
About the Authors