first parameter must be HttpRequest
the other parameters are the string matched by ( ) of urlpatterns
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)
沒有留言:
張貼留言