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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:36:31+00:00 2026-06-11T19:36:31+00:00

Maybe it’s just late, but I cannot figure out why this isn’t working. When

  • 0

Maybe it’s just late, but I cannot figure out why this isn’t working. When I have a post_save signal call a generic function, it works, but when I have a post_save signal call a method from a model, nothing happens. Here is code that works:

class Revision(models.Model):
    # Model junk...

def send_email(sender, instance, created, **kwargs):
    if created:
        print "DO STUFF"

signals.post_save.connect(send_email, sender=Revision)

But this does not work:

class Revision(models.Model):
    # Model junk...

    def send_email(sender, instance, created, **kwargs):
        if created:
            print "DO STUFF"

signals.post_save.connect(Revision.send_email, sender=Revision)

Is there a kind soul out there who will keep me from smashing my head into the wall? Thanks.

  • 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-11T19:36:32+00:00Added an answer on June 11, 2026 at 7:36 pm

    It seems to me that the problem in the second one is you are using an unbounded method send_mail. If you really want to call send_mail from within a class, maybe @classmethod or @staticmethod will help you out:

    class Revision(models.Model):
        # Model junk...
    
        @classmethod
        def send_email(cls, sender, instance, created, **kwargs):
            if created:
                print "DO STUFF"
    
    signals.post_save.connect(Revision.send_email, sender=Revision)
    

    or

    class Revision(models.Model):
        # Model junk...
    
        @staticmethod
        def send_email(sender, instance, created, **kwargs):
            if created:
                print "DO STUFF"
    
    signals.post_save.connect(Revision.send_email, sender=Revision)
    

    Alternatively without using these decorators, you can pass the bounded instance method:

    class Revision(models.Model):
    # Model junk...
    
        def send_email(self, sender, instance, created, **kwargs):
            if created:
                print "DO STUFF"
    
    signals.post_save.connect(Revision().send_email, sender=Revision)
    

    References:

    1. From the Django source code:

      def connect(self, receiver, sender=None, weak=True, dispatch_uid=None):
          """
          Connect receiver to sender for signal.
      
          Arguments:
      
              receiver
                  A function or an instance method which is to receive signals.
                  Receivers must be hashable objects.
      
                  If weak is True, then receiver must be weak-referencable (more
                  precisely saferef.safeRef() must be able to create a reference
                  to the receiver).
      
                  Receivers must be able to accept keyword arguments.
      
                  If receivers have a dispatch_uid attribute, the receiver will
                  not be added if another receiver already exists with that
                  dispatch_uid.
      
    2. Difference between @classmethod and @staticmethod: What is the difference between @staticmethod and @classmethod in Python?

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

Sidebar

Related Questions

Maybe this is a very simple question, but I just can not figure out.
Maybe I am being stupid, but this isn't making sense to me... I have
Maybe I just can't figure out the right keywords to get an answer out
Maybe I am out of my mind right now, but I have a question
Maybe this is very basic, but I am all confused. I have a simple
Maybe this is something I am just missing, but is there any way to
Maybe this is just how unapproved actions work (we're still testing)... I have gone
Maybe I'm just missing it, but isn't there a function equivalent to fprintf for
Maybe I misunderstood this but from what I read I may have several problems
Maybe this question is kind of silly but I have no clue how to

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.