[BangPypers] Django - Infinte Loop
Pradip Caulagi
ppc.lists at gmail.com
Thu Jul 10 07:42:18 CEST 2014
On Tuesday 08 July 2014 01:13 PM, Anand Reddy Pandikunta wrote:
> 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)*
Like others have noted, you should override model save. Another option
would be to use pre_save. Just set instance.status and don't call
instance.save?
More information about the BangPypers
mailing list