Chapter-17

Rendering Template Files for Each Application

17.1. Create Template Folder and Files :-

17.2. Add Templates in setting.py

17.3. render() :-

render( ) Function - It combines a given template with a given context dictionary and returns an HttpResponse object with that rendered text.
Syntax:-

render(request, template_name, context=dict_name, content_type = MIME_type, status=None, using=None)
Where,

request – The request object used to generate this response.

template_name – The full name of a template to use or sequence of template names. If a sequence is given, the first template that exists will be used. 

context – A dictionary of values to add to the template context. By default, this is an empty dictionary. If a value in the dictionary is callable, the view will call it just before rendering the template.

content_type – The MIME type to use for the resulting document. Defaults to 'text/html'.

status – The status code for the response. Defaults to 200.

using – The NAME of a template engine to use for loading the template.

PreviousNext