1 from django.core.management.base import BaseCommand, AppCommand
2 from optparse import make_option
3 from django.contrib.sites.models import Site
4 from django.conf import settings
5
6
8 help = "Configures the sites framework to use different domain name"
9 args = '[domain name] [optional site id]'
10
11 - def handle(self, dname, siteid=None, **options):
12 if not siteid:
13 siteid = settings.SITE_ID
14
15 s, created = Site.objects.get_or_create(pk=siteid)
16 s.domain = dname
17 s.name = dname
18 s.save()
19
20 print "Site ID %s is now configured to run at %s. \n (Your current settings point to SITE_ID = %s)\n Note: you may still need to change MEDIA_URL and STATIC_URL in settings\n" % (siteid, dname, settings.SITE_ID)
21