bitwit
bitwit

Reputation: 2676

Django return .html file directly without parsing for template tags at all

I'm writing a single view Javascript application with a Django backend that only needs to return the initial index.html and all other templates come from a CDN. My problem is that this first index.html file is parsing out some of my "{{}}" handlebars which I wanted to leave for the JS library to interpret.

I DO NOT want to use 'verbatim' or 'raw' or any additional tags because I don't want any django specific stuff in my static template files.

A possible alternative answer to this would be desmonstrating how to to make your inital index HTML response also come from the CDN but I didn't think that was possible.

Upvotes: 2

Views: 2817

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599480

If you don't want to render a template, simply don't render it. Django won't render anything unless you specifically call template.render or one of the shortcuts.

If you just want to return an HTML file, you could just open it as a normal file, read it, then return the content as the response.

Alternatively, as suggested in the comment, you can serve it as a static file.

Upvotes: 4

Related Questions