Hi, >From Django 1.7 onwards, the proper way to register signals will be inside a ready function <https://docs.djangoproject.com/en/dev/ref/applications/#django.apps.AppConfig.ready> in the app's configuration object. This is thanks to the App-loading refactor done in the release.
In your case, as mentioned in the docs, create an myapp/apps.py with : from django.apps import AppConfig class MyAppConfig(AppConfig): def ready(self): MyModel = self.get_model('MyModel') signals.post_save.connect(my_func, sender=MyModel) Also add a line to myapp/__init__.py : default_app_config = 'myapp.apps.MyAppConfig' This would eliminate circular imports. Cheers, Arun On Fri, Jul 11, 2014 at 12:37 PM, Anand Reddy Pandikunta < anand21na...@gmail.com> wrote: > I have overrided model save. > Moved couple of functions from models.py to tasks.py which lead to circular > imports. > Instead of importing models at the beginning of file, I've imported them in > the functions. > > Thank you @krace, @navin, @pradip :) > > > > On Thu, Jul 10, 2014 at 11:12 AM, Pradip Caulagi <ppc.li...@gmail.com> > wrote: > > > 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? > > > > _______________________________________________ > > BangPypers mailing list > > BangPypers@python.org > > https://mail.python.org/mailman/listinfo/bangpypers > > > > > > -- > - Anand Reddy Pandikunta > www.avilpage.com > www.quotes160.com > _______________________________________________ > BangPypers mailing list > BangPypers@python.org > https://mail.python.org/mailman/listinfo/bangpypers > _______________________________________________ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers