When i use assert false method,i get error :
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
Here is my code:
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)
I write code that is in The definite guide to django part2 .But it get error and i can`t understand what it is bad in this code.Thanks for help.