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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:08:43+00:00 2026-05-25T23:08:43+00:00

In the following sample code: from django.db import models from django.db.models.signals import pre_save #

  • 0

In the following sample code:

from django.db import models
from django.db.models.signals import pre_save

# Create your models here.
class Parent(models.Model):
    name = models.CharField(max_length=64)

    def save(self, **kwargs):
        print "Parent save..."
        super(Parent, self).save(**kwargs)

def pre_save_parent(**kwargs):
    print "pre_save_parent"
pre_save.connect(pre_save_parent, Parent)

class Child(Parent):
    color = models.CharField(max_length=64)

    def save(self, **kwargs):
        print "Child save..."
        super(Child, self).save(**kwargs)

def pre_save_child(**kwargs):
    print "pre_save_child"
pre_save.connect(pre_save_child, Child)

pre_save_parent doesn’t fire when I a Child is created:

child = models.Child.objects.create(color="red")

Is this expected behaviour?

  • 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-25T23:08:44+00:00Added an answer on May 25, 2026 at 11:08 pm

    There’s an open ticket about this, #9318.

    Your workaround looks fine. Here are two others suggested on the ticket by benbest86 and alexr respectively.

    1. Listen on the child class signal, and send the Parent signal there.

      def call_parent_pre_save(sender, instance, created, **kwargs):
          pre_save.send(sender=Parent, instance=Parent.objects.get(id=instance.id), created=created, **kwargs)
      pre_save.connect(call_parent_pre_save, sender=Child)
      
    2. Do not specify the sender when connecting the signal, then check for subclasses of parent.

      def pre_save_parent(sender, **kwargs):
          if not isinstance(instance, Parent):
              return
          #do normal signal stuff here
          print "pre_save_parent"
      
      pre_save.connect(pre_save_parent)
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a django application I have the following model: class Appointment(models.Model): #some other fields
I have the following sample code. class bar is derived from the base class
I have downloaded sample code from Apple Center.I also have gone through following question:
I have the following sample code which doesn't seem to want to run. import
The following sample code: import token, tokenize, StringIO def generate_tokens(src): rawstr = StringIO.StringIO(unicode(src)) tokens
The following sample code is from Joe Armstrong's Programming Erlang book: max(N) -> Max
I have the following (sample)code to filter search results from a LLBLGen data source:
I am going through some sample code from Apple. The following 5 statements are
I am a newbie to PHP development. I tried following code sample from PHP5
I have the following sample code which gets a list of values from a

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.