Add a management command to create a site.
This commit is contained in:
parent
2858f25e22
commit
cb93534a9e
|
@ -0,0 +1,13 @@
|
||||||
|
from django.contrib.sites.models import Site
|
||||||
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
help = 'Add a site'
|
||||||
|
|
||||||
|
def add_arguments(self, parser):
|
||||||
|
parser.add_argument('domain', type=str)
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
site = Site.objects.create(domain=options['domain'], name=options['domain'])
|
||||||
|
self.stdout.write(self.style.SUCCESS('Created site {}'.format(site)))
|
Loading…
Reference in New Issue