Pages on SITE_ID=2 give 404 Error if not logged in #1881

RacingTadpole opened this Issue May 25, 2013 · 16 comments


None yet

4 participants


I just created a vanilla site with Django-CMS 2.4.1 and Django 1.5.1. I put two sites in, SITE_IDs 1 and 2, and then added pages to each using the admin panel, and published them.

Site 1 works fine.

The problem is that some of site 2's pages give 404 errors if you are not logged in. (The ok pages seem to be the home page, and pages with app-hooks.)

Has anyone else had this problem? (I also posted this at stackoverflow here:

thank you!

@yakky yakky added a commit to yakky/django-cms that referenced this issue May 27, 2013
@yakky yakky Added tentative test for bug #1881 1ecc414

Could you have a look a this test : yakky@1ecc414 ?
It currently passes and apparently it checks the error conditions you described


Yes, that does look like it's the situation I describe - when I try that on my site, a similar test fails.

I appreciate your looking into it!

Can you point me to what other settings you are using in that test? I'd like to compare them against mine to help me find the issue. Thanks!

Divio AG member

you can find the settings in cms/test_utils/ but beware that 2 are overwritten in the test.

Divio AG member

I was able to reproduce this in CMS 3.x


Maybe linked to #1885 ?


I just realised I missed your setUp method when I tested it on my site, and I see that you have self.login_user_context(u) in there. I actually only found the problem if you were not logged in.

When I run your setUp and test methods on my site (just changing the template name and language), it passes there too. But if I add the line self._login_context.__exit__(None, None, None) to test_site_publish before getting the page URL, I get AssertionError: 404 != 200. Is that a sensible test?


@yakky yakky referenced this issue May 29, 2013

Test for #1881 #1891


Actually the test fails for the wrong reason :)
I fixed the test



I tried putting your newly changed test ( into my own code, and I have a question.

How should I adapt the line lang_settings[3][1]['public'] = True for a single language in my settings? Using either 0 or 1 instead of 3 gave an IndexError.

Without this line, the test fails for me.

Divio AG member

try: lang_settings[1][0]['public'] = True

Divio AG member

do you have USE_I18N = True or False?


Interesting. With lang_settings[1][0]['public'] = True it fails for me.

I have pretty standard settings, I think. The language-y ones are:

USE_TZ = True
USE_I18N = True
USE_L10N = True
    1: [
            'code': 'en',
            'name': gettext('English'),
            'public': True,
    'default': {
        'fallbacks': ['en',],
        'public': False,
    ('en', 'English'),

Hi, in an effort to pinpoint the problem, I have created as simple a test case as I can which demonstrates it:

There is no problem when I do this: I can see both pages of both sites whether logged in or not.

However, when I add the CMS_LANGUAGES setting described at, I see the problem: I can only see page 2 of site 2 if I am logged in.

I then changed LANGUAGE_CODE to 'en' (the tutorial uses 'en-us'), but this does not help.

I have uploaded this project to github at: . This also includes your test (slightly modified for English only) in sampletests. The URL of page 2 on site 2 is /test.

This project includes the data as a fixture - I typed:
python dumpdata sites cms text --indent 2 > sampletests/fixtures/cms.json
so you can quickly set up the database with python loaddata cms.

Sorry it took me so long to get a simple demonstration to you - I really appreciate your effort so far!


You don't have a CMS_LANGUAGES entry for site 2, so default takes effect, and in the snippet above, default has public=False which hides the language for the website 2.
Maybe we should change that line in the tutorial to defaults to True?


Ah! Thank you! That's great to know. I must admit I used that CMS_LANGUAGES setting without trying to understand it... I didn't realise the "1" key was a SITE_ID, though it is clearly stated in the docs now that I look. Can I suggest including an explanation of the "public" setting in the docs too?


Is there, actually:
But I guess that public=False in code is misleading.
@digi604: is False for a reason? Could we change that value to True?


Fixed in #1944

@yakky yakky closed this Jun 24, 2013
@yakky yakky added a commit to yakky/django-cms that referenced this issue Aug 17, 2013
@yakky yakky Added tentative test for bug #1881 57a5deb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment