liveBook · Manning

Server-side rendering

As explained in Django in Action

Server-side rendering is the composition of a web page's HTML on the server before it is sent to a browser.

Server-side rendering composes a web page’s HTML on the server before sending it to the browser. In Django, a URL selects a view, the view calls the template engine, and the resulting HTML becomes the browser’s response. section 1.0 section 1.2.1

The important boundary is where the page gets assembled:

  • Server-side rendering assembles the template’s pieces on the server and sends completed HTML to the browser. section 1.2.1
  • A single-page application assembles HTML in the browser using downloaded JavaScript, application logic, and data from the server. section 1.2.1
  • Django can support either approach: its view can render HTML or serve data, commonly as JSON, to a browser-based application. section 1.2.1

A Django page request

A visitor enters a URL in the browser. Django routes that URL to a Python view; the view invokes the template engine, which combines reusable HTML pieces into a completed page and sends it back. The browser displays that HTML, but the server performed the composition. section 1.0 section 1.2.1

How Django in Action covers it

How deep it goes
Defines the server-browser boundary and request flow, but stops short of implementation code or deployment details.
Examples
Uses a Django view selected by a URL and a template engine that combines reusable HTML pieces into a browser response.
What it assumes
Assumes a browser and server mental model while distinguishing server-side page composition from browser-side application logic.
What you can do after
Apply it via Django by connecting a URL to a view that renders a template and returns HTML to the browser.
How it connects
Connects server-side rendering with Django views, URL routing, template engines, single-page applications, JSON, and web APIs.

Also explained in

Compare how 8 books explain server-side rendering →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Django in Action. The section links point to the parts of the book it draws on.