jeffci
jeffci

Reputation: 2622

Django CMS pages throwing 404 for users who are not logged in to the admin

All the pages throw a 404 error on a site for users who are not logged in. But if I log in to the admin and go back to view the site, all the pages are fine and viewable.

I've been using Django CMS for years and haven't come across this before. The only difference with this site is the default language is french, in my settings I have:

LANGUAGES = [
    ('fr', 'Francais'),
]

as my LANGUAGES setting and here is my LANGUAGE_CODE

LANGUAGE_CODE = 'fr' 

Here are my urls.py

from django.conf.urls.defaults import *
from django.contrib import admin
from django.conf import settings

admin.autodiscover()

urlpatterns = patterns('',
    (r'^admin/', include(admin.site.urls)),
    url(r'^', include('cms.urls')),
)

if settings.DEBUG:
    urlpatterns = patterns('',
    url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
        {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
    url(r'', include('django.contrib.staticfiles.urls')),
) + urlpatterns

and my middleware...

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'cms.middleware.multilingual.MultilingualURLMiddleware',
    'cms.middleware.page.CurrentPageMiddleware',
    'cms.middleware.user.CurrentUserMiddleware',
    'cms.middleware.toolbar.ToolbarMiddleware',
)

What could be the cause of this?

Upvotes: 0

Views: 1001

Answers (2)

niceguydave
niceguydave

Reputation: 400

I was in a similar situation to you: I'm using multiple languages with Django-CMS.

My issue was related to the CMS_LANGUAGES variable I'd defined: I'd simply lifted a portion of the example from the docs.

A comment on a GitHub issue helped point me in the correct direction.

I'd previously had the variable set up as:

CMS_LANGUAGES = {
    ...
    'default': {
        'fallbacks': ['en', 'de', 'fr'],
        'redirect_on_fallback': False,
        'public': False,
        'hide_untranslated': False,
    }
}

Notice the definition of the public boolean.

Also, make sure that you follow the instructions in the documentation with respect to setting up your language variables within the CMS_LANGUAGES dictionary.

Replacing the above with 'public': True got things working for me again.

Upvotes: 3

danielcorreia
danielcorreia

Reputation: 2136

Just add a plus sign :)

if settings.DEBUG:
    urlpatterns += patterns('',

Upvotes: 2

Related Questions