Django returning static HTML in views.py?
<p>So I have a standard <code>Django</code> project with a basic view that returns a simple HTML confirmation statement. Would it be plausible for me to define all of my HTML in the view itself as a really long string and return that using <code>HttpResponse()</code> I know it's a bit <code>unorthodox</code>, but this is an example of what I'm thinking about:</p>

<pre><code>from django.shortcuts import render
from django.http import HttpResponse
from django.shortcuts import render_to_response

def index(request):
    html = """
&lt;html&gt;
  &lt;body&gt;
    This is my bare-bones html page.
  &lt;/body&gt;
&lt;/html&gt;
"""
    return HttpResponse(html)
</code></pre>

<p>My corresponding <code>JS</code> and <code>stylesheets</code> would be stored in the same directory as views. py in my app in this example. Just making sure: I'm not asking if this works, because I already know the answer is yes, I just want to know if there are any disadvantages/drawbacks to this method, and why don't more people do this?</p>

<p>You can use built-in <a href="https://docs.djangoproject.com/en/1.10/ref/templates/api/#django.template.Template.render" rel="nofollow">template renderer</a> to get works filters/templatetags/etc </p>

python html django http httpresponse