[BangPypers] Django - Infinte Loop
Anand Reddy Pandikunta
anand21nanda at gmail.com
Tue Jul 8 09:43:02 CEST 2014
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
More information about the BangPypers
mailing list