Web development with Python 3.1

Albert Hopkins marduk at letterboxes.org
Wed Oct 28 23:48:40 CET 2009

On Wed, 2009-10-28 at 16:38 +0200, Dotan Cohen wrote:
> > return HttpResponse(unmaintanable_html % data)
> >
> That's fine for single variables, but if I need to output a table of
> unknown rows?  I assume that return means the end of the script.
> Therefore I should shove the whole table into a variable and then copy
> that variable to the array "data"?
No, if you use a templating system like Django's then basically you pass
a QuerySet to your template.  A QuerySet is basically a pointer to a SQL
query, for example.  The templating system just knows to expect an
iterable, it can be a list of rows or it can be a QuerySet which does a
fetch from a database.  No need to shove an entire table into a
> > - second solution: do basically the same thing with a template
> system -
> > which will give you much more power and options...
> >
> I will look further into the Django templates, I promise. But I would
> still like to know how to work with Python proper.

Another advantage if templates for many is that it allows programmers to
do what they do best (write code) while letting web designers do what
they do best (designing web pages) without them walking over each other
(that much).

More information about the Python-list mailing list