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.
class MyClass(models.Model):
....
def before_save(self, sender, instance, *args, **kwargs):
self.test_field = "It worked"
I've tried putting pre_save.connect(before_save, sender='self') in 'MyClass' itself, but nothing happens.
I've also tried putting it at the bottom of the models.py file:
pre_save.connect(MyClass.before_save, sender=MyClass)
I read about connecting signals to class methods here, but can't figure out the code.
Anybody know what I'm doing wrong?