python - Django-CMS: Multiple domains on same project -


i'm trying run django-cms on 2 different domains. created 2 domains (django.contrib.sites) , added them django-cms pages. created sitedetectionmiddleware:

class sitedetectionmiddleware:   def process_request(self, request):     settings.site_id = 1     host = request.meta.get('http_host')     if host:       try:         site = site.objects.get(domain=host)         settings.site_id = site.id       except site.doesnotexist:         pass 

it seems work correctly, when call website in browser first time after restarting apache. changed other site , got noreversematch error.

does have idea wrong?

i thought should work out of box in django-cms?

regards colin

why setting site_id statically? should create 2 settings files , use form of inheritance depending on project differentiation, e.g.:

local_settings.py (not under version control holds sensitive data database passwords , secret key)

secret_key = 'as!sfhagfsa@$1ajfs78787124!897zr81' 

settings.py (holds settings equal both sites)

# preferably @ bottom try:     local_settings import * except importerror:     pass 

settings_foo.py (holds settings specific site 1)

from settings import *  site_id = 1 

settings_bar.py (holds settings specific site 2)

from settings import *  site_id = 2 

settings_deployment_foo.py (overwrites variables production)

from settings_foo import *  debug = false 

settings_deployment_bar.py (overwrites variables production)

from settings_bar import *  debug = false 

then create 2 sites within admin/sites or use fixture (assuming sharing database cross these projects you'll have once).


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -