From 2507aac14f4592079577b3d346c025bac32c2446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastia=CC=81n=20Magri=CC=81?= Date: Sat, 19 Jul 2014 10:16:31 -0430 Subject: [PATCH] Fix default Site ID to use settigns.SITE_ID This fixes syncdb when using mongodb-engine as the default SITE_ID=1 is not a valid ObjectID in MongoDB. Setting a valid SITE_ID is already suggested by mongodb-engine, but it does not have any effect if the SITE_ID is hardcoded for the default site. --- django/contrib/sites/management.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/django/contrib/sites/management.py b/django/contrib/sites/management.py index 7a29e82d4cdf..ed336353023b 100644 --- a/django/contrib/sites/management.py +++ b/django/contrib/sites/management.py @@ -5,6 +5,7 @@ from django.db.models import signals from django.db import connections from django.db import router +from django.conf import settings from django.contrib.sites.models import Site from django.contrib.sites import models as site_app from django.core.management.color import no_style @@ -19,7 +20,7 @@ def create_default_site(app, created_models, verbosity, db, **kwargs): # can also crop up outside of tests - see #15346. if verbosity >= 2: print("Creating example.com Site object") - Site(pk=1, domain="example.com", name="example.com").save(using=db) + Site(pk=settings.SITE_ID, domain="example.com", name="example.com").save(using=db) # We set an explicit pk instead of relying on auto-incrementation, # so we need to reset the database sequence. See #17415.