diff --git a/blogs/parser.py b/blogs/parser.py index fd5e4b54d..55cf693b8 100644 --- a/blogs/parser.py +++ b/blogs/parser.py @@ -48,10 +48,12 @@ def update_blog_supernav(): pass else: rendered_box = _render_blog_supernav(latest_entry) - box, _ = Box.objects.update_or_create( + box, created = Box.objects.update_or_create( label='supernav-python-blog', defaults={ 'content': rendered_box, 'content_markup_type': 'html', } ) + if not created: + box.save() diff --git a/downloads/models.py b/downloads/models.py index 4576afb2f..415804b6e 100644 --- a/downloads/models.py +++ b/downloads/models.py @@ -179,13 +179,15 @@ def update_supernav(): 'last_updated': timezone.now(), }) - box, _ = Box.objects.update_or_create( + box, created = Box.objects.update_or_create( label='supernav-python-downloads', defaults={ 'content': content, 'content_markup_type': 'html', } ) + if not created: + box.save() def update_download_landing_sources_box(): @@ -208,13 +210,15 @@ def update_download_landing_sources_box(): return source_content = render_to_string('downloads/download-sources-box.html', context) - source_box, _ = Box.objects.update_or_create( + source_box, created = Box.objects.update_or_create( label='download-sources', defaults={ 'content': source_content, 'content_markup_type': 'html', } ) + if not created: + source_box.save() def update_homepage_download_box(): @@ -234,13 +238,15 @@ def update_homepage_download_box(): content = render_to_string('downloads/homepage-downloads-box.html', context) - box, _ = Box.objects.update_or_create( + box, created = Box.objects.update_or_create( label='homepage-downloads', defaults={ 'content': content, 'content_markup_type': 'html', } ) + if not created: + box.save() @receiver(post_save, sender=Release) diff --git a/successstories/models.py b/successstories/models.py index e5345b435..cb3fd7418 100644 --- a/successstories/models.py +++ b/successstories/models.py @@ -102,13 +102,15 @@ def update_successstories_supernav(sender, instance, created, **kwargs): 'story': instance, }) - box, _ = Box.objects.update_or_create( + box, created = Box.objects.update_or_create( label='supernav-python-success-stories', defaults={ 'content': content, 'content_markup_type': 'html', } ) + if not created: + box.save() # Purge Fastly cache purge_url('/box/supernav-python-success-stories/')