I have an html file that I generated by creating a visualization using the Bokeh library. I'd like to include it within my django site, however, I get a TemplateSyntaxError when I attempt to add it as a view. It appears that some of the syntax in the page is conflicting with Django's templating system.
How do I go about having Django serve the page without attempting to parse it as a template?
Based on the base template docs, you can just return an HttpResponse directly, without using any render functions:
https://docs.djangoproject.com/en/1.8/topics/http/views/
Since the HttpResponse just takes a string for the response content, you could just read the raw file in from wherever it is stored, and return it this way.
When you use render_to_response
or render
, this just loads the template, parses it, constructs the resulting string, and returns it wrapped in an HttpResponse anyway, so if you don't want to do any rendering, you can skip the template system entirely.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With