django_cms url 问题中的强制语言:TypeError at / string indices must be integers

django_cms forced language in url problem : TypeError at / string indices must be integers

我正在尝试使用 divio - django-cms, 但是每当我尝试连接到本地服务器时,我都会因为我的本地语言而出错。

我试图删除 settings.py 的语言代码片段但没有成功,因为它引发了另一个错误

TypeError at /
string indices must be integers

**Request Method:   GET
Request URL:    http://54.180.150.144:52761/
Django Version: 1.11.21
Exception Type: TypeError
Exception Value:    
string indices must be integers
Exception Location: /workspace/heydj/venv/lib/python3.6/site-packages/cms/utils/conf.py in _ensure_languages_settings, line 205
Python Executable:  /workspace/heydj/venv/bin/python3
Python Version: 3.6.5
Python Path:    
['/workspace/djcms_r',
 '/workspace/heydj/venv/lib/python36.zip',
 '/workspace/heydj/venv/lib/python3.6',
 '/workspace/heydj/venv/lib/python3.6/lib-dynload',
 '/usr/local/lib/python3.6',
 '/workspace/heydj/venv/lib/python3.6/site-packages']
Server time:    WED, 5 July 2019 10:47:35 +0000**

在 settings.py 中是这样的:

"""        {
            'code': 'RU',
            'name': gettext('RU'),
            'redirect_on_fallback': True,
            'public': True,
            'hide_untranslated': False,
        },"""

当我更改代码时,它会抛出另一个错误,如找不到页面 使用 djcms_r.urls 中定义的 URLconf,Django 按以下顺序尝试了这些 URL 模式:

^media/(?P<path>.*)$
^static\/(?P<path>.*)$
^sitemap\.xml$
^ko/ ^admin/
^ko/ ^ ^cms_login/$ [name='cms_login']
^ko/ ^ ^cms_wizard/
^ko/ ^ ^(?P<slug>[0-9A-Za-z-_.//]+)/$ [name='pages-details-by-slug']
^ko/ ^ ^$ [name='pages-root']

当前路径 /ko/ 与其中任何一个都不匹配。

我尝试使用“export LC_ALL=C”更改 linux 语言

但还是不行。

我该如何解决这个错误? 谢谢

LANGUAGES = (
    [('en', 'en-us')]
   # [('en-us','en')]
    ## Customize this
    #('RU', gettext('RU')),
)


CMS_LANGUAGES = {
    ## Customize this
    1: [
          {
            'code': 'en',
            'name': gettext('English'),
            'fallbacks': ['de', 'fr'],
            'public': True,
            'hide_untranslated': True,
            'redirect_on_fallback':False,
        },
        
        
   
"""        {
            'code': 'ko',
            'name': gettext('ko'),
            'redirect_on_fallback': True,
            'public': True,
            'hide_untranslated': False,
        },"""
    ],
    'default': {
        'redirect_on_fallback': True,
        'public': True,
        'hide_untranslated': False,
    },
}

LANGUAGE_CODE = 'en'

也许您注释掉了不应该的“自定义此”部分。

为了给你另一种解决方案,你不妨考虑更改你的 linux 本地配置。