Search code examples
pythondjangodjango-cms

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


I am trying to use divio - django-cms, but whenever I try to connect to local server, I get error because of my local language.

I tried to delete the settings.py's language code snippets but in vain since it raised another eror like

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**

In the settings.py it goes like :

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

When I change the code, it throws another error like page not found Using the URLconf defined in djcms_r.urls, Django tried these URL patterns, in this order:

^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']

The current path, /ko/, didn't match any of these.

I tried to change the linux language using "export LC_ALL=C"

but it doesn't work too.

How can I fix this error? Thank you

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'

Solution

  • Maybe you commented out the "customize this" part which shouldn't be.

    And just for giving you another solution to it, you might as well consider change your linux local configure.