django-cms

文档

install

需要装 virtualenv, 参看 python 的 virtualenv

用 python3

virtualenv -p python3 venv
source venv/bin/activate

pip install djangocms-installer

建立项目

mkdir tutorial-project
cd tutorial-project
djangocms -f -p . mysite

Pillow报错

出现了报错

*****************************************************************

Check documentation at https://djangocms-installer.readthedocs.io

*****************************************************************

Traceback (most recent call last):
  File "/Users/bigzhu/cms/venv/bin/djangocms", line 11, in <module>
    sys.exit(execute())
  File "/Users/bigzhu/cms/venv/lib/python3.6/site-packages/djangocms_installer/main.py", line 36, in execute
    install.check_install(config_data)
  File "/Users/bigzhu/cms/venv/lib/python3.6/site-packages/djangocms_installer/install/__init__.py", line 79, in check_install
    raise EnvironmentError('\n'.join(errors))
OSError: Pillow is not installed check for installation errors and see "Libraries installation issues" documentation section: https://djangocms-installer.readthedocs.io/en/latest/libraries.html

Pillow 在 python 2.7 下有一个, 但这里 pip install 时会报 Pillow 已有了, virtualenv 如何能不受到全局包的影响呢? 先去把全局的包卸载了, 再装就可以了.

语言错误

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 327, in execute
    django.setup()
  File "/Library/Python/2.7/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Library/Python/2.7/site-packages/django/apps/registry.py", line 115, in populate
    app_config.ready()
  File "/Library/Python/2.7/site-packages/django/contrib/admin/apps.py", line 22, in ready
    self.module.autodiscover()
  File "/Library/Python/2.7/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
    autodiscover_modules('admin', register_to=site)
  File "/Library/Python/2.7/site-packages/django/utils/module_loading.py", line 50, in autodiscover_modules
    import_module('%s.%s' % (app_config.name, module_to_search))
  File "/Users/bigzhu/cms/venv/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "/Users/bigzhu/cms/venv/lib/python3.6/site-packages/cms/admin/__init__.py", line 2, in <module>
    import cms.admin.pageadmin
  File "/Users/bigzhu/cms/venv/lib/python3.6/site-packages/cms/admin/pageadmin.py", line 41, in <module>
    from cms.admin.forms import (
  File "/Users/bigzhu/cms/venv/lib/python3.6/site-packages/cms/admin/forms.py", line 85, in <module>
    class PageForm(forms.ModelForm):
  File "/Users/bigzhu/cms/venv/lib/python3.6/site-packages/cms/admin/forms.py", line 86, in PageForm
    language = forms.ChoiceField(label=_("Language"), choices=get_language_tuple(),
  File "/Users/bigzhu/cms/venv/lib/python3.6/site-packages/cms/utils/i18n.py", line 79, in get_language_tuple
    return [(lang['code'], lang['name']) for lang in get_languages(site_id)]
  File "/Users/bigzhu/cms/venv/lib/python3.6/site-packages/cms/utils/i18n.py", line 24, in get_languages
    result = get_cms_setting('LANGUAGES').get(site_id)
  File "/Users/bigzhu/cms/venv/lib/python3.6/site-packages/cms/utils/conf.py", line 278, in get_cms_setting
    return COMPLEX[name]()
  File "/Users/bigzhu/cms/venv/lib/python3.6/site-packages/cms/utils/conf.py", line 233, in get_languages
    'LANGUAGE_CODE "%s" must have a matching entry in LANGUAGES' % settings.LANGUAGE_CODE
django.core.exceptions.ImproperlyConfigured: LANGUAGE_CODE "en-us" must have a matching entry in LANGUAGES
The installation has failed.


*****************************************************************

Check documentation at https://djangocms-installer.readthedocs.io

*****************************************************************

Traceback (most recent call last):
  File "/Users/bigzhu/cms/venv/bin/djangocms", line 11, in <module>
    sys.exit(execute())
  File "/Users/bigzhu/cms/venv/lib/python3.6/site-packages/djangocms_installer/main.py", line 41, in execute
    django.setup_database(config_data)
  File "/Users/bigzhu/cms/venv/lib/python3.6/site-packages/djangocms_installer/django/__init__.py", line 396, in setup_database
    output = subprocess.check_output(command, env=env)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/Users/bigzhu/cms/venv/bin/python3.6', '-W', 'ignore', 'manage.py', 'migrate']' returned non-zero exit status 1.

mac 是的语言是 en-us, 而 djangocms 用的是 en, 匹配不上报错了.

指定语言搞定

djangocms -f -p . mysite --languages cn

启动

python manage.py runserver

访问 http://127.0.0.1:8000/ 报错

  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/wsgiref/handlers.py", line 137, in run
    self.result = application(self.environ, self.start_response)
  File "/Library/Python/2.7/site-packages/django/contrib/staticfiles/handlers.py", line 63, in __call__
    return self.application(environ, start_response)
  File "/Library/Python/2.7/site-packages/django/core/handlers/wsgi.py", line 177, in __call__
    response = self.get_response(request)
  File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 113, in get_response
    urlconf = settings.ROOT_URLCONF
  File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 56, in __getattr__
    return getattr(self._wrapped, name)
AttributeError: 'Settings' object has no attribute 'ROOT_URLCONF'

ROOT_URLCONF 没有配置, 真是, 不知说什么好, 就不能做的方便点么?

vim mysite/settings.py

加入ROOT_URLCONF = 'mysite.urls'

用 admin:admin 登录进去, 只有一种语言 en-us

语言

没做什么多语支持, 跑是能跑起来了, 界面也很好看.