Check site.Site model
@@ -8,6 +8,7 @@ from django.conf import settings
from django.core.management.base import BaseCommand
from promgen import PROMGEN_CONFIG_DIR, PROMGEN_CONFIG_FILE
+from django.contrib.sites.models import Site
PROMGEN_CONFIG_DEFAULT = (
@@ -45,6 +46,23 @@ class Command(BaseCommand):
with path.open("w", encoding="utf8") as fp:
fp.write(value)
+ def site(self, **defaults):
+ """
+ Check our site object to ensure that we are not directed at example.com
+ """
+ site, created = Site.objects.get_or_create(
+ pk=settings.SITE_ID, defaults=defaults,
+ )
+ if site.domain == "example.com":
+ Site.objects.filter(pk=settings.SITE_ID).update(**defaults)
+ self.warning("site {:<15} : {domain} ({name})", settings.SITE_ID, **defaults)
+ else:
+ self.success("site {site.pk:<15} : {site.domain} ({site.name})", site=site)
+
+ def add_arguments(self, parser):
+ parser.add_argument("--domain", default="localhost:8000")
+ parser.add_argument("--name", default="Promgen")
+
def handle(self, **kwargs):
self.write("Bootstrapping Promgen", color=self.style.MIGRATE_HEADING)
@@ -62,7 +80,10 @@ class Command(BaseCommand):
else:
self.success("Config {} Exists", PROMGEN_CONFIG_FILE)
- self.write("Checking required settings", color=self.style.MIGRATE_HEADING)
+ self.write("Checking environment settings", color=self.style.MIGRATE_HEADING)
self.setting("SECRET_KEY", default=settings.SECRET_KEY)
self.setting("DATABASE_URL")
self.setting("CELERY_BROKER_URL")
+
+ self.write("Checking other settings", color=self.style.MIGRATE_HEADING)
+ self.site(domain=kwargs["domain"], name=kwargs["name"])
