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 7531717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:14:55+00:00 2026-05-30T05:14:55+00:00

Using the shell, I can do this: >>> from django.test.client import Client >>> from

  • 0

Using the shell, I can do this:

>>> from django.test.client import Client
>>> from django.test.utils import setup_test_environment
>>> setup_test_environment()
>>> c = Client()
>>> c.login(username="dev", password="password")
True
>>> r = c.get('/')
>>> r.status_code
200

Now with this in the test.py file:

from django.test.client import Client

__test__ = {"doctest": """
>>> c = Client()
>>> c.login(username='dev', password='password')
True
>>> r = c.get('/')
>>> r.status_code
200
"""}

I get this output:

Failed example:
    c.login(username="dev", password="password")
Expected:
    True
Got:
    False
------------------------------------------------------
Failed example:
    r.status_code
Expected:
    200
Got:
    302

I’ve looked all over the internet and I can’t find anything that helps with this situation. Any ideas?

On a similar note, I’ve commented out: from django.views.decorators.debug import sensitive_post_parameters and all @sensitive_post_parameters() decorators from my code because each time I run ./manage.py test app django complains:
Could not import app.views. Error was: No module named debug
Removing this decorator and import statement allows it to move forward.

Im very much lost and I need StackOverflow! Thanks everyone.

  • 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-05-30T05:14:57+00:00Added an answer on May 30, 2026 at 5:14 am

    sensitive_post_parameters is a new feature in Django 1.4, so if you’re running Django 1.3 or earlier then the import will fail.

    I believe that the commands you tried in the shell were run on the normal database. When you run your doc tests, Django will set up a test database. It looks like your user dev isn’t in the test database when you run the doc tests, so the login attempt fails. One option is to create the User with User.objects.create_user before you attempt the login. Another option is to use fixtures.

    With Django, I would recommend writing unit tests instead of doc tests. One big advantage is that it’s easy to include fixtures to load initial data (e.g. users) into the test database. Another is that Django takes care of refreshing the database between unit tests.

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

Sidebar

Related Questions

How can i see my django queries from manage shell interface I have tried
How can I execute a.exe using the Cygwin shell? I created a C file
How exactly using VB6 can I can call any Windows shell command as you
I am trying to run a Django management command from cron. I am using
How can I convert this string to have a space every 8th digit using
Currently I have the from django.contrib.auth.models import User but I'm confused as to how
Been using Django for < 1yr now, but this one is new-to-me. Hopefully someone?
I'm making a call to a program from the shell using the subprocess module
I'm using shell_exec() to execute a Twitter API Call. shell_exec('curl -u user:password -d id=3191321
How to compare two property files in two different folders using shell script input

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.