2008年7月14日 星期一

view function

first parameter must be HttpRequest
the other parameters are the string matched by ( ) of urlpatterns

ex:
def hours_ahead(request, offset):
offset=int(offset)
dt= datetime.datetime.now()+ datetime.timedelta(hours=offset)
html="<html><body>In %s hours(s), it will be %s.</body></html>"% (offset,dt)
return HttpResponse(html)

沒有留言: