Web development with Python 3.1
Bruno Desthuilliers
bruno.42.desthuilliers at websiteburo.invalid
Thu Oct 29 05:31:29 EDT 2009
Dotan Cohen a écrit :
>
>> Ok, here's a Django example without a template:
>>
>> # views.py
>> def index(request):
>> torvalds = request.GET.get("torvalds", "No torvalds here")
>> return HttpResponse("<html><body>%s</body></html>" % torvalds)
>>
>>
>
> Allright, but what if I need to output in the middle of the page? Say,
> one row of a table that is neither the end nor beginning of the code?
> I ask because the construct "return" makes me believe that this is not
> good for this purpose.
A django "view" function returns a full HttpResponse. It's nothing like
PHP's "server page" scheme - here you first build your full response,
then pass it back to the framework (which will deal with the frontal
webserver).
>
>> and here's an exemple using a template:
(snip)
> Again, how could I output something in the middle of the page with the
> templates?
Already answered elsewhere in this post.
More information about the Python-list
mailing list