Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
pre_remove and post_remove "actions" not sent via m2m_changed signalling?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jeff Blaine  
View profile  
 More options Jan 18, 11:47 am
From: Jeff Blaine <cjbla...@gmail.com>
Date: Wed, 18 Jan 2012 08:47:27 -0800 (PST)
Local: Wed, Jan 18 2012 11:47 am
Subject: pre_remove and post_remove "actions" not sent via m2m_changed signalling?

Hi all,

http://dpaste.org/1vhf6/

With the following models.py, and the output seen further

down, can anyone explain why pre_remove and post_remove

"actions" are not happening when I remove an item from

a M2M relation?

class Interface(models.Model):
    name = models.CharField('Interface',
                            primary_key=True,
                            max_length=80)

class Netgroup(models.Model):
    name = models.CharField('Netgroup',
                            primary_key=True,
                            max_length=80)

    interfaces = models.ManyToManyField(Interface,
                                        null=True,
                                        blank=True)

    def __unicode__(self):
        return self.name

from django.db.models.signals import m2m_changed

def tester(sender, **kwargs):
    action = kwargs['action']
    instance = kwargs['instance']
    pk_set = kwargs['pk_set']
    model = kwargs['model']
    fd = open('/tmp/m2m.log', 'a+')
    fd.write('%s on %s pk_set of %s is %s\n' % (action, instance, model, str(pk_set)))
    fd.close()

m2m_changed.connect(tester, dispatch_uid="whatever")

#===============================================================
#
# IN ADMIN UI: Removed 'barley.foo.org' from jbtest2 which

#              had 4 interfaces (and then has 3, correctly)

#
#              Logs the following...

#

#              Where's the "remove" actions?
#
#===============================================================

pre_clear on instance jbtest2: pk_set of <class 'hostdb.models.Interface'> is None
post_clear on instance jbtest2: pk_set of <class 'hostdb.models.Interface'> is None
pre_add on instance jbtest2: pk_set of <class 'hostdb.models.Interface'> is set([u'babylon.foo.org', u'ape.foo.org', u'baker.foo.org'])
post_add on instance jbtest2: pk_set of <class 'hostdb.models.Interface'> is set([u'babylon.foo.org', u'ape.foo.org', u'baker.foo.org'])


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeff Blaine  
View profile  
 More options Jan 18, 6:43 pm
From: Jeff Blaine <cjbla...@gmail.com>
Date: Wed, 18 Jan 2012 15:43:30 -0800 (PST)
Local: Wed, Jan 18 2012 6:43 pm
Subject: Re: pre_remove and post_remove "actions" not sent via m2m_changed signalling?

Answering my own question:  https://code.djangoproject.com/ticket/16073

:(

Thanks to IRC #django-users : carljm and domguard


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »