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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:05:56+00:00 2026-05-29T12:05:56+00:00

I’ve been testing my application and got stuck into error that does not seem

  • 0

I’ve been testing my application and got stuck into error that does not seem to have anything to do with the application itself. I have a unit test like this:

class TagSaveAndLoadTest(TestCase):
    fixtures = ['users.json']

    def setUp(self):
        self.client = Client()
        self.client.login(user='test_user', password='123')

    def test_register_save(self):  
        tag_dict = {
                        'sex' : 4,
                        'drugs' : 3,
                        'rocknroll' : 1,
                    }
        response = self.client.post('/register/save_tags/', {'skilltags' : json.dumps(tag_dict)})
        self.assertEqual(response.status_code, 200)

The error I get is: TypeError: int() argument must be a string or a number, not 'AnonymousUser'. Files appearing in the traceback are base.py, manages.py, query.py, etc. It seems like my request gets stuck somewhere in the middleware, and I have no idea how to deal with it. How is it even possible for the request not to reach my view or even controller? Why there is a problem with AnonymousUser if the ‘setUp()’ function logs a test user in?

Full traceback can be found here, thanks in advance!

  • 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-29T12:05:59+00:00Added an answer on May 29, 2026 at 12:05 pm

    Try not to be too intimidated by the traceback. The information you need is there, if you look up high enough past all the Django internals. The request is reaching your view, the problem isn’t in the middleware. It looks like the client.login call is not working. The following filter statement fails because request.user is an an anonymous user

    Skill.objects.filter(user=request.user).delete()
    

    Try printing the client.login line in your test. It will return True if it successfully logs the user in. If that doesn’t work, then check:

    1. You are using the correct username and password for your fixtures.
    2. You are loading the user fixtures successfully. Do you have the correct filename? The Django convention is user.json without an s.
    3. Make sure your test class subclasses the Django TestCase class so that the fixtures are loaded.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I need a function that will clean a strings' special characters. I do NOT
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.