# HG changeset patch # User grandjoncl # Date 1354267452 -3600 # Node ID ec918337fe411b6b2c06130d1ef91b78c45f2206 # Parent 7448fab0e138cb511a34faf80a177ca7b40b1694 new command : when we want to use an other database, we can run that command with "python manage.py initsitedomain" and this will set the domain to the right value in the django-site table diff -r 7448fab0e138 -r ec918337fe41 src/ldt/ldt/management/commands/initsitedomain.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ldt/ldt/management/commands/initsitedomain.py Fri Nov 30 10:24:12 2012 +0100 @@ -0,0 +1,21 @@ +from django.core.management.base import BaseCommand +from ldt.ldt_utils.models import Content, Project +from ldt.ldt_utils.contentindexer import ContentIndexer, ProjectIndexer +from django.conf import settings +from django.db import models +from django.contrib.sites.models import Site + +class Command(BaseCommand): + help = 'set the site domain to the right value according to the django settings' + + def handle(self, *args, **options): + site = Site.objects.get(id=settings.SITE_ID) + web_url = settings.WEB_URL + domain_area = web_url.split("//",1) + domain = domain_area[1] + if site.domain!=domain: + site.domain = domain + site.save() + if site.name!=domain: + site.name=domain + site.save() \ No newline at end of file