Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

signals for derived class have base class as source when cascading #30

Open
niki-sp opened this issue Apr 11, 2016 · 3 comments
Open

signals for derived class have base class as source when cascading #30

niki-sp opened this issue Apr 11, 2016 · 3 comments

Comments

@niki-sp
Copy link

niki-sp commented Apr 11, 2016

Given this doc-item hierarchy:

class BaseDoc(TypedModel):
   ...
class BaseDocItem(TypedModel):
   doc = models.ForeignKey(BaseDoc)
class MyDoc(BaseDoc):
    ...
class MyItem(BaseDocItem):
    ...

and post_delete signal handler for MyItem
then:
item.delete() fires post_delete signal with source=MyItem
but doc.delete() fires post_delete signal with source=BaseDocItem
expected result:
without TypedModel post_delete is always fired with source=MyItem

@craigds
Copy link
Owner

craigds commented Apr 12, 2016

Interesting. See #1 which could be related.

Could you post the code that connects the signals?

@niki-sp
Copy link
Author

niki-sp commented Apr 12, 2016

@receiver(post_delete, sender=BaseDocItem) # extra registration
@receiver(post_delete, sender=MyItem)
def handler(sender, instance, **kwa):
    ...

i am using extra registration line as workaround

@niki-sp
Copy link
Author

niki-sp commented Apr 12, 2016

I have working post_save signal handler for MyDoc and MyItem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants