Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8283931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:55:11+00:00 2026-06-08T10:55:11+00:00

When i use assert false method,i get error : assertionError at /time/plus/2/ No exception

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T10:55:12+00:00Added an answer on June 8, 2026 at 10:55 am

    assert False always throws an exception, it’s meant for testing. more information on testing here

    I suppose you can just remove that line and your function should work as expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For a long time I would throw up a DebugBreak() or ASSERT(false) in the
In vb.net doing debug.assert (false) will set a break point. I can then use
Is it a good practice to use Assert for function parameters to enforce their
The best practice seems to be to use assert for a condition that should
If I want to make a rule dynamic so i can use assert after
I was wondering, I am aware you can use assert to add facts or
I want to use the Assert keyword in my android apps to destroy my
I'm trying to create an assert method in Javascript. I've been struggling with arguments.callee.caller
Trying to use NUnit to test a method that adds an object to a
I use Assert.Fail a lot when doing TDD. I'm usually working on one test

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.