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
authorgrandjoncl
Fri, 30 Nov 2012 10:24:12 +0100
changeset 999 ec918337fe41
parent 998 7448fab0e138
child 1000 0b8497f071d1
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
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