Re: Creation of default site not triggering post_save signal

2016-09-13 Thread Simon Charette
Hi Matt, The recommended pattern is to register signal receivers in your app config's ready() method[1]. From the Django documentation: > Where should this code live? > > Strictly speaking, signal handling and registration code can live anywhere you > like, although it’s recommended to avoid

Re: Creation of default site not triggering post_save signal

2016-09-12 Thread Matt Thompson
Hi Simon, Thank you very much for your prompt reply! I've added the following to my app, which seems to work just fine: @receiver(models.signals.post_migrate) def gen_site_config_post_migrate(plan, **kwargs): # A migration of the `django.contrib.sites` app was applied. if plan and

Re: Creation of default site not triggering post_save signal

2016-09-10 Thread Simon Charette
Hi Matt, I worked on the changes that broke your code. Starting with 1.10 the migration signals are passed an `apps` kwarg representing the state of models before and after the specified migrations are applied. This allows signal receivers to manipulate model definitions that are synchronized

Creation of default site not triggering post_save signal

2016-09-10 Thread Matt Thompson
Hi All, I have a small Django app that uses the sites framework and has a post_save signal on Site that does some bits and bobs when a new site is created. On 1.9.7, when you run migrations for the first time, it correctly triggers the post_save signal. However, after upgrading to 1.10.1,