开发者

django-cms + grappelli

开发者 https://www.devze.com 2023-02-23 10:36 出处:网络
If anyone knows how to make django-cms play with grappelli, please give some tips开发者_运维百科Well I\'ve just gone through a fairly epic adventure, the story of which might be of some use to you. T

If anyone knows how to make django-cms play with grappelli, please give some tips开发者_运维百科


Well I've just gone through a fairly epic adventure, the story of which might be of some use to you. The end point of said adventure was getting django-cms 2.1.3 working with django-filebrowser-no-grappelli . Whilst that may sound in fact like the opposite of what you want, I ended up there because what I really wanted was to get django-cms working with filebrowser. Without grappelli though the standard django-filebrowser does not work as expected. But with grappelli django-cms does not work as expected. So therein lay the rub, to quote shakespeare. Getting django-cms working with filebrowser was relatively straight forward except for the fact that when trying to upload files with uploadify (which is shipped with filebrowser), after selecting the files in the file dialog, nothing happened. Eventually I figured out that this was because the jquery library was being loaded twice: once by filebrowser for use with uploadify, and once by django-cms. So by commenting out the second line in this file:

your site packages dir/cms/templates/cms/toolbar/toolbar.html

which loads jquery.min.js, uploadify worked as expected. Soooo...if you just want to get django-cms working with grappelli so you can use filebrowser, the above might be helpful. Here is my settings file for reference.


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/


I've once made a django-cms fork on github that supports grappelli, it's a bit outdated, but maybe helps you to get started or probaly you'd like to contribute.

0

精彩评论

暂无评论...
验证码 换一张
取 消