Does Django render web pages on the server side?

Viewed 5634

Does Django render websites and serve them from a views folder similar to how the express framework works in JavaScript? Or does it render pages on the client side similar to an applicatipn running express in the back-end and some fron end framework such as Vue.js in the front-end

3 Answers

Django can do either, but it is designed to render on the server side in its default configuration, not the client side.

To use server side rendering, use Django as intended and according to the many tutorials out there.

To use client side rendering with something like React or Vue, use the Django Rest Framework.

If you are talking about the template language, it happens on the backend. This is true of every framework and every language. In the templates, the placeholders are replaced, they produce a valid html/javascript page, and that's what is returned to the browser (or, to whatever accessed that url). Essentially, it is a shortcut for creating an html file by concatenating strings.

A suggestion: don't use the template language, in any backend framework. Just use django to create rest services that return the data, and use a front-end framework like Vue/angular/react to create the actual front end part.

It's now 2022 and you should definitely check out https://www.reactivated.io/.

It effectively is plain old Django with server-rendered React.

Related