I am trying to define a \"before_save\" method in certain classes in my django 1.2 project. I\'m having trouble connecting the signal to the class method in models.py.
A working example with classmethod:
class MyClass(models.Model):
#....
@classmethod
def before_save(cls, sender, instance, *args, **kwargs):
instance.test_field = "It worked"
pre_save.connect(MyClass.before_save, sender=MyClass)
There's also a great decorator to handle signal connections automatically: http://djangosnippets.org/snippets/2124/