django-cms + grappelli

后端 未结 3 1760
逝去的感伤
逝去的感伤 2021-01-17 17:32


If anyone knows how to make django-cms play with grappelli, please give some tips

3条回答
  •  借酒劲吻你
    2021-01-17 18:35

    My solution is to implement 2 subdomains, 'www' and 'cms', in each of which a separate instance of the Django site is running with a different STATIC_ROOT and a modified INSTALLED_APPS. grappelli runs in the 'www' subdomain. It is not running in the 'cms' subdomain, so that you can use django-cms there.

    • Set up a subdomain: cms.example.com

    • Modify your webserver to serve this subdomain. Use the same settings as your main django site but point to a different script handler. e.g. if using wsgi direct the server to run wsgi_cms.py

    • cp wsgi.py wsgi_cms.py. Edit wsgi_cms.py and change the line

      os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings") to os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings_cms")

    • settings_cms.py :

    :

    from settings import *
    
    INSTALLED_APPS.remove('grappelli.dashboard')
    INSTALLED_APPS.remove('grappelli')
    STATIC_ROOT = os.path.join('/what/ever/static_cms/')
    STATIC_URL = '/static_cms/'
    ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/`
    
    • modify settings.py: change INSTALLED_APPS from a tuple to a list

    • restart web servers

    • ./manage.py collectstatic --settings=myproject.settings_cms

    • your regular site continues as normal. To edit django-cms pages with grappelli disabled go to http://cms.example.com/admin/cms/page/

提交回复
热议问题