nephila / djangocms-multisite

django-multisite support for DjangoCMS
BSD 3-Clause "New" or "Revised" License
26 stars 19 forks source link

tuple indices must be integers or slices, not str #19

Closed tsturzenegger closed 5 years ago

tsturzenegger commented 6 years ago

Hi

If i install djangocms-multisite according to the guide. I get the following traceback:

Environment:

Request Method: GET
Request URL: http://localhost:8000/

Django Version: 1.10.7
Python Version: 3.5.2
Installed Applications:
('djangocms_admin_style',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.admin',
 'django.contrib.sites',
 'django.contrib.sitemaps',
 'django.contrib.staticfiles',
 'django.contrib.messages',
 'cms',
 'menus',
 'sekizai',
 'treebeard',
 'djangocms_text_ckeditor',
 'filer',
 'easy_thumbnails',
 'djangocms_column',
 'djangocms_link',
 'cmsplugin_filer_file',
 'cmsplugin_filer_folder',
 'cmsplugin_filer_image',
 'cmsplugin_filer_utils',
 'djangocms_style',
 'djangocms_snippet',
 'djangocms_googlemap',
 'djangocms_video',
 'multisite',
 'djangocms_multisite',
 'cmsplugin_contact_plus',
 'image_gallery',
 'post_office',
 'news',
 '...')
Installed Middleware:
('multisite.middleware.DynamicSiteMiddleware',
 'cms.middleware.utils.ApphookReloadMiddleware',
 'djangocms_multisite.middleware.CMSMultiSiteMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'cms.middleware.user.CurrentUserMiddleware',
 'cms.middleware.page.CurrentPageMiddleware',
 'cms.middleware.toolbar.ToolbarMiddleware',
 'cms.middleware.language.LanguageCookieMiddleware')

Traceback:

File "/.../env/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
  42.             response = get_response(request)

File "/.../env/lib/python3.5/site-packages/django/core/handlers/base.py" in _legacy_get_response
  244.             response = middleware_method(request)

File "/.../env/lib/python3.5/site-packages/djangocms_multisite/middleware.py" in process_request
  17.                 urlconf = settings.MULTISITE_CMS_URLS[host]

Exception Type: TypeError at /
Exception Value: tuple indices must be integers or slices, not str

I don't exactly know if there is something unusual with my setup, however I could fix the issue if I change the following file: /.../env/lib/python3.5/site-packages/djangocms_multisite/middleware.py

urlconf = settings.MULTISITE_CMS_URLS[host]

to

urlconf = settings.MULTISITE_CMS_URLS[0][host]

Could this be a general error?

Kind regards Tobias

jhonvidal commented 6 years ago

Hi, I'm with the same problem, if anyone can solve it, please let us know

aaratn commented 6 years ago

Same issue with django version 1.9 and djangocms version 3.4.5, djangocms-multisite version 0.1.1

haricot commented 6 years ago

if there is a comma (,) at the end of the dict, that turn it into a tuple and there is this error.

MULTISITE_CMS_URLS={
    'www.example.com': 'tests.test_utils.urls1',
    'www.example2.com': 'tests.test_utils.urls2',
},

Delete the comma and it will work.

yakky commented 5 years ago

Thanks the new readme in #20 fixed the issue, sorry it took so long to provide a feedback