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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:32:42+00:00 2026-06-17T23:32:42+00:00

I have a custom method inside one of the Django models, it does some

  • 0

I have a custom method inside one of the Django models, it does some routine DB data fetching and summing. Here is it:

from django.utils.timezone import utc, now 
...


class Project(models.Model):
...
    def getTotalMonthlyBackers(self, monthdate=now()):
        from pledger.models import DonationHistory 

        return (DonationHistory.objects
                                 .filter(project=self)
                                 .filter(datetime_sent__gte=datetime(monthdate.year, monthdate.month, 1))
                                 .aggregate(Count('user', distinct=True))['user__count'])

when I try to call the method through

print project.getTotalMonthlyBackers()

I’m getting error: 'NoneType' object is not callable

However if I output the method itself just to check if it’s not a typo:

print project.getTotalMonthlyBackers

I get: <bound method Project.getTotalMonthlyBackers of <Project: Putty>>

So the method is there and bound to the certain Project object.
There is something very obvious in Python I can’t get about calling this method, but I couldn’t figure it out from the manuals.

Traceback:

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/mnt/hgfs/Projects/BitFund/Sources/source/project/views/project_view_details.py" in view
  101.     print project.getTotalMonthlyBackers()
File "/mnt/hgfs/Projects/BitFund/Sources/source/project/models.py" in getTotalMonthlyBackers
  76.                                  .filter(datetime_sent__gte=datetime(monthdate.year, monthdate.month, 1))

Exception Type: TypeError at /putty_1
Exception Value: 'NoneType' object is not callable
  • 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-17T23:32:43+00:00Added an answer on June 17, 2026 at 11:32 pm

    It seems that you haven’t imported the datetime constructor yet, also if you use it you will get a naive datetime, which will produce a warming because that structure doesn’t contain a tzinfo object, so try using a Time Zone aware constructor for that datetime or use the make_aware.

    Check out this piece of documentation about the topic, and I’m sure you will solve it in the most proper way Timezones and utils

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

Sidebar

Related Questions

I have created a custom shipping method to show depo-names from which customers will
I am newbie at Django. I have model with a custom method. In view
I have a Custom ViewGroup with some views inside. In response to an event,
I have two helper methods inside a custom View which are called by their
I have created a custom method that will return unique items, together with the
I have a custom listview and made overlapping very simple: in onDraw method, I
I have a class with a custom each-method: class CurseArray < Array def each_safe
I have a custom class named CatalogItem which I receive in a method, as
I have a question regarding providing a custom delete-method to boost::shared_ptr constructor. For example,
I have a custom validation in the enterprise validation block. The DoValidate method is

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.