0

I'm creating an instance of a model (Container), and it seems like the pre_save function is not triggered.

This is the class in the 'signals':

class ContainerCreatedMixin(object): @staticmethod @receiver(pre_save, sender=Container) def container_pre_save(sender, instance, **kwargs): # create container folder if not created yet if instance.folder_created_at is None: is_folder_created = ContainerCreatedMixin().create_folder(instance) if is_folder_created: instance.folder_created_at = now() def create_virtual_folder(self, container): try: ...... 
2
  • 1
    Have you imported that file anywhere so that the signal is registered? Commented Sep 17, 2017 at 11:15
  • That's what I was missing! you can write it as answer and I'll mark it. Commented Sep 17, 2017 at 12:08

1 Answer 1

3

Using the receiver decorator on a class method doesn't really make sense.

Put your decorated method out of class and it should be registered if the file is imported. Also, there is no need of creating Mixings for the following.

Sign up to request clarification or add additional context in comments.

1 Comment

The specific issue was that I missed the import. Thanks.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.