Web development with Python 3.1

Dotan Cohen dotancohen at gmail.com
Wed Oct 28 14:32:42 CET 2009

>>>> While I know that to be true in the general sense, from what I've
>>>> looked at Django and other frameworks it seems that the web frameworks
>>>> push the coder to use templates, not letting him near the HTML.
>>> Well... there must be a reason, for sure... No ?
>> ֹYes, but I don't like it.
> Why so ? What's your problem with templating systems, exactly ?

They don't give me the control over the HTML that I would like. I'm
probably stuck in 1998 when they didn't exist, but I like to write the
HTML myself.

>>>> Django and the other frameworks seem to
>>>> force the user to use templates.
>>> Not at all. Nothing prevents you from shooting yourself in the foot and
>>> generating HTML "by hand" in your view functions (or request handler
>>> methods
>>> etc, depending on the framework).
>> How is this done in Django, then?
> def index(request):
>    unmaintanable_html = """
> <html>
>  <head>
>    <title>Index</title>
>  </head>
>  <body>
>    <h1>Embedded HTML is a PITA</h1>
>    <p>but some like pains...</p>
>  </body>
> </html>
> """
>    return HttpResponse(unmaintanable_html)

And if I need to add a variable or three in there? Static HTML I can
do without Python.

Dotan Cohen


More information about the Python-list mailing list