assert false メソッドを使用すると、エラーが発生します。
assertionError at /time/plus/2/
No exception supplied
Request Method: GET
Request URL: http://localhost:8000/time/plus/2/
Django Version: 1.4
Exception Type: AssertionError
Exception Location: C:\my\my\views.py in hours_ahead, line 18
これが私のコードです:
from django.http import HttpResponse, Http404
import datetime
def hello(request):
return HttpResponse("Hello World")
def current_datetime(request):
now = datetime.datetime.now()
html = "<html><body>it is now %s.</body></html>" % now
return HttpResponse(html)
def hours_ahead(request, offset):
try:
offset = int(offset)
except ValueError:
raise Http404()
dt = datetime.datetime.now() + datetime.timedelta(hours=offset)
assert False
html = "<html><body>In %s hours,it will be %s.</body></html>" % (offset, dt)
return HttpResponse(html)
djangoパート2の明確なガイドにあるコードを書いていますが、エラーが発生し、このコードの何が悪いのか理解できません。助けてくれてありがとう。