Hi,

*models.py*

*def my_func(sender, instance, created, **kwargs):*
*      # do something*
*      instance.status = 'task completed'*
*      instance.save()*

*class MyModel(models.Model):*
*      status = models.CharField(max_length=100, blank=True)*
*      # some code*

*signals.post_save.connect(my_func, sender=MyModel)*


I am using post_save signal to connect to a function.

If a new instance of model is saved, post_save signal connects to my_func.
Once the function is executed, I am updating status of the model.
This is again sending post_save signal which is leading to infinite loop.

I want to execute my_func only once and update status many times.
Does any one know how to do this?


-- 
- Anand Reddy Pandikunta
www.avilpage.com
www.quotes160.com
_______________________________________________
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers

Reply via email to