Skip to content
Snippets Groups Projects
Commit e417b3b6 authored by Fredrik Jonsson's avatar Fredrik Jonsson
Browse files

Added a wagtailsiteupdate command.

parent 8887b936
No related branches found
No related tags found
No related merge requests found
from django.core.management.base import BaseCommand
from django.db import transaction
from wagtail.core.models import Site
class Command(BaseCommand):
help = "Wagtail site update script. Requires a public hostname, a apply hostname and a port number in that order."
def add_arguments(self, parser):
parser.add_argument('public', type=str, help='Hostname for the public site.')
parser.add_argument('apply', type=str, help='Hostname for the apply site.')
parser.add_argument('port', type=int, help='Port to use for all sites.')
@transaction.atomic
def handle(self, *args, **options):
site_apply = Site.objects.get(id=2)
site_apply.hostname = options['apply']
site_apply.port = options['port']
site_apply.save()
site_public = Site.objects.get(id=3)
site_public.hostname = options['public']
site_public.port = options['port']
site_public.save()
self.stdout.write(f"Updated the public site to {options['public']}:{options['port']} and the apply site to {options['apply']}:{options['port']}.")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment