It’s possible to enable different themes for different sites using ‘goscale.themes’ app.
It’s a combination of modified django-cms-themes and django-dynamicsites
Currently it’s possible to theme:
To use themes add ‘goscale.themes’ to INSTALLED_APPS:
INSTALLED_APPS = (
...
'goscale',
'goscale.themes',
)
Add ‘static’ context processor:
TEMPLATE_CONTEXT_PROCESSORS = (
...
'goscale.themes.context_processors.static',
)
Add ‘SiteOnFlyDetectionMiddleware’ middleware before any other:
MIDDLEWARE_CLASSES = (
'goscale.themes.site_middleware.SiteOnFlyDetectionMiddleware',
...
)
Create a new Theme in django admin and upload a theme tarball (tar.gz) file or put your theme files into ‘themes’ directory in your project and input the theme name.
Choose a Site to which this theme should apply.
After that you should have theme templates in your Page editing form.
For more information refer to django-cms-themes website.
For theme static files:
{{ STATIC_THEME_URL }}
For current theme name:
{{ GOSCALE_THEME }}
The beauty of goscale.themes app is that you can serve multiple themes and sites from the same django project instance. It’s enabled by SiteOnFlyDetectionMiddleware from django-dynamicsites.
You can switch themes dynamically by hosts in your browser.
For more information refer to django-dynamicsites documentation.
To enable multiple hosts for one theme (for example local, dev, staging servers) use SITE_ALIASES setting:
SITE_ALIASES = {
'goscalecms.ru': 'goscalecms.com',
}
The pattern for theme switching locally is:
{{theme}}.127.0.0.1.xip.io:{{port}}
So let’s say you’re running your server on localhost:8000. And you want to open theme goscale, then open:
http://goscale.127.0.0.1.xip.io:8000/