From 9f181066e7461cee49cc5df7ce021fbd756900ce Mon Sep 17 00:00:00 2001 From: Diederik van der Boor Date: Wed, 7 Oct 2015 15:26:51 +0200 Subject: [PATCH] Fix initial site creation, to check for SITE_ID Fix suggested in #90 by @mrmachine --- fluent_pages/migrations/0001_initial.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fluent_pages/migrations/0001_initial.py b/fluent_pages/migrations/0001_initial.py index f2a7c782..c518e83f 100644 --- a/fluent_pages/migrations/0001_initial.py +++ b/fluent_pages/migrations/0001_initial.py @@ -10,12 +10,12 @@ def make_site(apps, schema_editor): Site = apps.get_model("sites", "Site") - if Site.objects.count() == 0: - site = Site() - site.pk = settings.SITE_ID - site.name = 'example' - site.domain = 'example.com' - site.save() + Site.objects.get_or_create( + pk=settings.SITE_ID, + defaults=dict( + name='example', + domain='example.com', + )) def remove_site(apps, schema_editor):