Can I use post_save with the listener being a method of a class?
What I want:
class UpdCatalog(models.Model):
file = models.FileField(upload_to="catalog/")
class SomeClass:
def codeType(text):
row_code = text[0], text[1]
return row_code, row_type
def main(sender, instance, created, **kwargs):
text = ["q", "w", "e". "r"]
row_code, row_type = codeType(text)
signals.post_save.connect(SomeClass.main, sender=UpdCatalog)
When I try run this code main isn’t called. There are no errors.
When the listener is not in the class everything works fine.
You need to study the difference between function and instance method. And in your case you can use
staticmethoddecorator.