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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:41:18+00:00 2026-05-28T07:41:18+00:00

Here is my problem. I am trying to add instrumentation to my code which

  • 0

Here is my problem. I am trying to add instrumentation to my code which is based off Django. Here is what I do:

def trace(func):
  def wrapped(*args, **kwargs):
    print func.__name__
    return func(*args, **kwargs)
  return wrapped

def trace_class_func(kclass, func):
  setattr(kclass, func.__name__, classmethod(trace(func.im_func)))


# Trace all the calls to 'get_query_set' from all the classes or subclasses of Manager
tracer.trace_class_func(models.Manager, models.Manager.get_query_set)

This class is stored inside the module “tracer” and I add ‘tracer’ in the INSTALLED_APPS section of settings.py (note that the ‘tracer’ module’ is added at the last).

However, when I run my app, I get this error:

Exception Type: AttributeError at /settings/integrations/
Exception Value: type object ‘UserManager’ has no attribute ‘model’

This happens inside django/db/models/manager.py in get_query_set function.

EDIT: The deal is that when I tried to print the contents of UserManager class (which is derived from models.Manager), only the fields defined in UserManager were being recognized and none of the fields from the base class:

self: <class 'django.contrib.auth.models.UserManager'>
keys: {'__module__': 'django.contrib.auth.models', 'create_superuser': <function create_superuser at 0x10d44eaa0>, 'create_user': <function create_user at 0x10d44ea28>, 'make_random_password': <function make_random_password at 0x10d44eb18>, '__doc__': None, '__init__': <function __init__ at 0x10d44e9b0>}

As it can be seen, even the functions defined by UserManager are only being printed, not the ones defined by models.Manager. Not sure why this is happening, though.

Does anybody have an idea what is going on here? Because when I run this tracer on my custom made classes (including base and inherited classes), it works perfectly, so I am guessing this is a Django error, either in my configuration or something else.

  • 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-28T07:41:18+00:00Added an answer on May 28, 2026 at 7:41 am

    The problem is that get_query_set isn’t a class method. The instance itself is ignored and thus self != instance, it’s the class which doesn’t have a model.

    A class method receives the class itself as the first argument, not the instance.

    class MyClass(object):
       @classmethod
       def foo(cls):
           print "i'm a class: {0}".format(cls)
    # i'm a class: __main__.MyClass
    
    class MyClass(object):
       def foo(self):
           print "i'm a class instance: {0}".format(self)
    # i'm a class instance: <__main__.MyClass instance at 0x1064abef0>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to solve the problem here but I don't know why my code
Here is a problem I am trying to solve: I have an irregular shape.
Here's my problem - I'm trying to access a session namespace across actions .
(see here for the problem I'm trying to solve) How do you get hibernate
I have an interesting problem here I've been trying to solve for the last
I am stuck with a small problem here.. What i am trying to do
Here's a problem I've been trying to solve at work. I'm not a database
Here is my problem. I am trying to write a small simple game engine
Here's my problem. I'm currently trying to develop a .Net Compact Framework 2.0 application
So Here is the Problem, I am trying to get that circle to align

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.