Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Django render web pages on the server side?

Tags:

python

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

like image 490
Huseyn Iskandarli Avatar asked Jan 26 '23 17:01

Huseyn Iskandarli


2 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.

like image 114
Matthew Gaiser Avatar answered Feb 16 '23 13:02

Matthew Gaiser


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.

like image 26
blue_note Avatar answered Feb 16 '23 14:02

blue_note