Some problems starting with FeinCMS

351 views
Skip to first unread message

etienned

unread,
May 3, 2012, 12:03:00 AM5/3/12
to Django FeinCMS
Hi,

I'm currently evaluating Django-CMS and FeinCMS for my site. Currently
FeinCMS look more tempting to me but I have a few problems and
questions to be fix/answer before choosing it definitely.

I need a CMS basically for 2 things: adding some basic content pages
(about, etc.) and managing the different menus (main menu, footer
menu, etc.) that will be mostly on every page of my site. Most of the
site content is produce by other custom apps. But most of these apps
don't have any pages/templates for the moment.

I'm with Django 1.3.1 and FeinCMS 1.5.1.

1. I did some basic tests inspired by the docs and the example
project. The admin part works fine. The problem is when I try to
render a frontend page I got this error: "ContentNotRenderedError The
response content must be rendered before it can be accessed.". I dig
into the code and the problem come from the `add_never_cache_headers`
function in the handler. This function try to access the content of
the response but the content look like is not render yet? If I remove
the `add_never_cache_headers` function the page renders correctly.

2. When running syncdb the first time, I hit a problem (I'm using
MySQL). It's the issue https://github.com/feincms/feincms/issues/261.
The problem is still there because in CS c3dc229 the max_length was
lower to 300 but the maximum allowed on a VARCHAR in MySQL (prior to
ver. 5.0.3) is 255. But I think their's also a problem with key limit
(767 bytes) because I still have this bug with MySQL 5.1.31. If I set
the max_length to 255 I don't have the problem.

3. My site is multilingual and I would like to have URLs prefixed by
the language (fr, en) like this site http://zff.com/. How can I
achieve that with FeinCMS?

4. How to add a menu entry that point to one of the URL of my custom
app?

5. Is it possible to use reversion on the Pages? How?

6. What's the best strategies for my use case? I think I should create
a base template that include my different menus, each one in its own
block and then create a main block that will be fill by Page for the
basic pages and overriden in other templates specific to my custom
apps. Is it the way to go?

Thank you

sbaechler

unread,
May 3, 2012, 2:21:32 AM5/3/12
to django-...@googlegroups.com
Hi

I can help you with the questions 3 to 6.

Make sure you add your languages to settings.py. You simply have to create a page tree for every language. FeinCMS helps you there. If you create a tree for one language you can simply click on translation and it will create the same tree structure in that language for you. Simply change the slug of the root page to the language code. i.e. 'de'. 

Add a view for the root URL that redirects to one of the language pages. Here is an example from zff:

def redirect_to_language(request, slug=''):
    if not slug=="":
        slug += '/'
    
    return HttpResponseRedirect('/%s/%s' % (request.LANGUAGE_CODE[:2], slug))



There is currently no versioning on the pages in FeinCMS.

For your project I would just create one base template for the content pages and use the application content for your custom apps. Custom apps can now overwrite the base template completely.
If you are talking about template blocks, that's the way to go. 

Regards
Simon

Matthias Kestenholz

unread,
May 3, 2012, 3:12:18 AM5/3/12
to django-...@googlegroups.com
Hi Etienne

I'll answer the questions not answered by Simon already.


On Thu, May 3, 2012 at 6:03 AM, etienned <etienne....@gmail.com> wrote:
> Hi,
>
> I'm currently evaluating Django-CMS and FeinCMS for my site. Currently
> FeinCMS look more tempting to me but I have a few problems and
> questions to be fix/answer before choosing it definitely.
>
> I need a CMS basically for 2 things: adding some basic content pages
> (about, etc.) and managing the different menus (main menu, footer
> menu, etc.) that will be mostly on every page of my site. Most of the
> site content is produce by other custom apps. But most of these apps
> don't have any pages/templates for the moment.
>
> I'm with Django 1.3.1 and FeinCMS 1.5.1.
>
> 1. I did some basic tests inspired by the docs and the example
> project. The admin part works fine. The problem is when I try to
> render a frontend page I got this error: "ContentNotRenderedError The
> response content must be rendered before it can be accessed.". I dig
> into the code and the problem come from the `add_never_cache_headers`
> function in the handler. This function try to access the content of
> the response but the content look like is not render yet? If I remove
> the `add_never_cache_headers` function the page renders correctly.

That's a bit unfortunate. The add_never_cache_headers function is
needed so that content delivered when frontend editing is active is
never cached.

As long as you don't use frontend editing you should be fine by just
removing this line, though. Can you open a ticket on the github issue
tracker with the full traceback so that we can solve this problem in
FeinCMS itself?


> 2. When running syncdb the first time, I hit a problem (I'm using
> MySQL). It's the issue https://github.com/feincms/feincms/issues/261.
> The problem is still there because in CS c3dc229 the max_length was
> lower to 300 but the maximum allowed on a VARCHAR in MySQL (prior to
> ver. 5.0.3) is 255. But I think their's also a problem with key limit
> (767 bytes) because I still have this bug with MySQL 5.1.31. If I set
> the max_length to 255 I don't have the problem.

Yes, this is a known problem. I did not get any responses on my
comment on this issue yet. We use MySQL on a few sites as well and
everything seems to work alright.


> 3. My site is multilingual and I would like to have URLs prefixed by
> the language (fr, en) like this site http://zff.com/. How can I
> achieve that with FeinCMS?
>
> 4. How to add a menu entry that point to one of the URL of my custom
> app?
>
> 5. Is it possible to use reversion on the Pages? How?

Yes. We even have step-by-step instructions for that:
http://www.feinheit.ch/media/labs/feincms/versioning.html

There's a problem with reversion 1.6 you have to be aware of, though.
It's fixed in 'next', the fix removes compatibility with earlier
versions of reversion and will not be available in the 1.5 series of
FeinCMS because of that.
https://github.com/feincms/feincms/issues/266


> 6. What's the best strategies for my use case? I think I should create
> a base template that include my different menus, each one in its own
> block and then create a main block that will be fill by Page for the
> basic pages and overriden in other templates specific to my custom
> apps. Is it the way to go?

Sounds good. Maybe have a look at this page as well:
http://www.feinheit.ch/media/labs/feincms/integration.html

Most of the time we aren't using different base templates for
different parts of a site. Maybe a base template for standard content
and a template for the home page. I rarely use more than two templates
but there aren't any hard and fast rules for that, it's mostly a
question of style.


HTH
Matthias

Martin J. Laubach

unread,
May 3, 2012, 4:06:55 AM5/3/12
to django-...@googlegroups.com
Add a view for the root URL that redirects to one of the language pages. Here is an example from zff:

def redirect_to_language(request, slug=''):
    if not slug=="":
        slug += '/'
    
    return HttpResponseRedirect('/%s/%s' % (request.LANGUAGE_CODE[:2], slug))

  Actually, you don't even need that. Just add a page (we usually call it "Root Redirector", with override url set to "/" and redirect to set to the entry page in your default language (the first one in LANGUAGES). It will figure out by itself that there are translations and redirect you to the appropriate language.

        mjl

Matthias Kestenholz

unread,
May 3, 2012, 4:11:23 AM5/3/12
to django-...@googlegroups.com
Really nice -- I completely forgot about this one. I stumbled over it
a few weeks ago but it didn't stick around.

Matthias

Etienne Desautels

unread,
May 3, 2012, 2:53:08 PM5/3/12
to django-...@googlegroups.com

Hi Matthias,

Wow, it's true that you (the FeinCMS community) give an excellent (and fast) support on the list!

On 2012-05-03, at 03:12, Matthias Kestenholz wrote:

>> 1. I did some basic tests inspired by the docs and the example
>> project. The admin part works fine. The problem is when I try to
>> render a frontend page I got this error: "ContentNotRenderedError The
>> response content must be rendered before it can be accessed.". I dig
>> into the code and the problem come from the `add_never_cache_headers`
>> function in the handler. This function try to access the content of
>> the response but the content look like is not render yet? If I remove
>> the `add_never_cache_headers` function the page renders correctly.
>
> That's a bit unfortunate. The add_never_cache_headers function is
> needed so that content delivered when frontend editing is active is
> never cached.

Yes, I know...

> As long as you don't use frontend editing you should be fine by just
> removing this line, though.

Unfortunately I'm predicting that I will use it.

> Can you open a ticket on the github issue
> tracker with the full traceback so that we can solve this problem in
> FeinCMS itself?

Yes, I'll do that later today.

>> 2. When running syncdb the first time, I hit a problem (I'm using
>> MySQL). It's the issue https://github.com/feincms/feincms/issues/261.
>> The problem is still there because in CS c3dc229 the max_length was
>> lower to 300 but the maximum allowed on a VARCHAR in MySQL (prior to
>> ver. 5.0.3) is 255. But I think their's also a problem with key limit
>> (767 bytes) because I still have this bug with MySQL 5.1.31. If I set
>> the max_length to 255 I don't have the problem.
>
> Yes, this is a known problem. I did not get any responses on my
> comment on this issue yet. We use MySQL on a few sites as well and
> everything seems to work alright.

The real problem is with the index of the _cached_url Field. Indexes are limited to 767 bytes in MySQL with InnoDB. If you use UTF-8 each characters need 3 bytes so the real limit is 767 bytes / 3 = 255 characters.

So if it works for you with MySQL there's 3 possibilities:
1. You're using MyISAM, the limit is 1000 bytes, so 1000 bytes / 3 = 333 characters, so max_length=300 works.
2. You're not using UTF-8 so each character use 1 byte.
3. You didn't take care of the warning when running syncdb, so you don't have the index.

I understand the dilemma exposed in the issue. Possible solutions I see:
1. Don't put an index for _cached_url.
2. Create a shorter index in a post_syncdb signal or in a SQL file.
3. Keep max_length to 255.

Maybe the best solution is 2 with the post_syncdb signal. This way it will be possible to create a shorter index only for MySQL?

>> 5. Is it possible to use reversion on the Pages? How?
>
> Yes. We even have step-by-step instructions for that:
> http://www.feinheit.ch/media/labs/feincms/versioning.html

Ah, excellent!

> There's a problem with reversion 1.6 you have to be aware of, though.
> It's fixed in 'next', the fix removes compatibility with earlier
> versions of reversion and will not be available in the 1.5 series of
> FeinCMS because of that.
> https://github.com/feincms/feincms/issues/266

Ok I can deal with that. Thanks for mentioning.

>> 6. What's the best strategies for my use case? I think I should create
>> a base template that include my different menus, each one in its own
>> block and then create a main block that will be fill by Page for the
>> basic pages and overriden in other templates specific to my custom
>> apps. Is it the way to go?
>
> Sounds good. Maybe have a look at this page as well:
> http://www.feinheit.ch/media/labs/feincms/integration.html

Great.

Regards
Etienne

Etienne Desautels

unread,
May 3, 2012, 3:46:43 PM5/3/12
to django-...@googlegroups.com

Hi Simon,

Thanks for the fast answer.

On 2012-05-03, at 02:21, sbaechler wrote:
> Make sure you add your languages to settings.py. You simply have to create a page tree for every language. FeinCMS helps you there. If you create a tree for one language you can simply click on translation and it will create the same tree structure in that language for you. Simply change the slug of the root page to the language code. i.e. 'de'.

Ah, I see. Thats make sense.

> Add a view for the root URL that redirects to one of the language pages. Here is an example from zff:
>
> def redirect_to_language(request, slug=''):
> if not slug=="":
> slug += '/'
>
> return HttpResponseRedirect('/%s/%s' % (request.LANGUAGE_CODE[:2], slug))

For the moment I'm using Martin's solution but it's good to know that I can do this to customize further the language redirection.
I had already read this page, but now I have re-read it and I think I understand how I can really control my menus contents.

> There is currently no versioning on the pages in FeinCMS.

Hmm, look at Matthias answer ;-)

> For your project I would just create one base template for the content pages and use the application content for your custom apps. Custom apps can now overwrite the base template completely.
> If you are talking about template blocks, that's the way to go.

Yes, I was talking about template blocks. Great.

Regards
Etienne

Etienne Desautels

unread,
May 3, 2012, 4:02:18 PM5/3/12
to django-...@googlegroups.com

Martin,

On 2012-05-03, at 04:06, Martin J. Laubach wrote:

> Actually, you don't even need that. Just add a page (we usually call it "Root Redirector", with override url set to "/" and redirect to set to the entry page in your default language (the first one in LANGUAGES). It will figure out by itself that there are translations and redirect you to the appropriate language.

That's a nice solution. If I understand correctly does this means that:
1. If a visitor visit the root and his browser is set to English it will be redirected to /en/?
2. If a visitor visit the root and his browser is set to French it will be redirected to /fr/?
3. If a visitor, with a browser set to English, click on the French link, after that, if is going to the root it will be redirected to /fr/?

I've added the LocalMiddleware and it look it partly works but if django_language=fr and I go on an english page django_language don't change to en?

Also is it possible to redirect a visitor to the in his browser language if come from a link in another language? Ex: he click on example.com/en/about/ in Google but his browser is in French so it will be redirected to example.com/fr/a-propos/.

Thanks

Regards
Etienne

Martin J. Laubach

unread,
May 3, 2012, 5:58:06 PM5/3/12
to django-...@googlegroups.com
That's a nice solution. If I understand correctly does this means that:
1. If a visitor visit the root and his browser is set to English it will be redirected to /en/?
2. If a visitor visit the root and his browser is set to French it will be redirected to /fr/?
3. If a visitor, with a browser set to English, click on the French link, after that, if is going to the root it will be redirected to /fr/?

  1 and 2, yes. 3, I don't know.

        mjl

Etienne Desautels

unread,
May 3, 2012, 10:41:50 PM5/3/12
to django-...@googlegroups.com

Matthias,

On 2012-05-03, at 03:12, Matthias Kestenholz wrote:
>> 1. I did some basic tests inspired by the docs and the example
>> project. The admin part works fine. The problem is when I try to
>> render a frontend page I got this error: "ContentNotRenderedError The
>> response content must be rendered before it can be accessed.". I dig
>> into the code and the problem come from the `add_never_cache_headers`
>> function in the handler. This function try to access the content of
>> the response but the content look like is not render yet? If I remove
>> the `add_never_cache_headers` function the page renders correctly.
>
> That's a bit unfortunate. The add_never_cache_headers function is
> needed so that content delivered when frontend editing is active is
> never cached.
>
> As long as you don't use frontend editing you should be fine by just
> removing this line, though. Can you open a ticket on the github issue
> tracker with the full traceback so that we can solve this problem in
> FeinCMS itself?

Before opening the ticket I tried to reproduce the problem. So first, I uncommented the 2 lines concerning the `add_never_cache_headers` function. To my surprise I didn't get the bug anymore. So I reverted my own code to the state where I had this bug. Still can't reproduce it. So I clean the DB and enter new pages and no more luck, still no bug.

After some reflexions I think I know the cause of the bug. In my first tests I mess a bit with the main template name. And now I remember that when I was creating some pages the (only) radio button of the model was unset, probably because of the mess I did with the template name. That's for sure what was causing the ContentNotRenderedError.

So I'm not opening an issue.

I'm pretty sure I'll go with FeinCMS now.

Thanks for the support.

Etienne

Etienne Desautels

unread,
May 3, 2012, 11:06:21 PM5/3/12
to django-...@googlegroups.com

Matthias,

Just after sending my previous post I got the idea to try the frontend editing. And when it's activated the bug is there. So I have open an issue: https://github.com/feincms/feincms/issues/285

Etienne
Regards

Etienne Desautels

unread,
May 3, 2012, 11:39:09 PM5/3/12
to django-...@googlegroups.com

One last problem I have: when clicking on the "View on site" button in the admin (from the changelist or the edit page) the linked URL is in this form:
http://127.0.0.1:8888/admin/r/107/1/

but the response his
Location http://example.com/fr/

?

Etienne
Regards

Martin J. Laubach

unread,
May 4, 2012, 8:03:23 AM5/4/12
to django-...@googlegroups.com
but the response his
Location http://example.com/fr/

  That's a wrong setting in the "sites" table, make sure the entry with the SITE_ID does indeed match what it should be.

  This behaviour is rather annoying really, but it's django, nothing to do with feincms.

        mjl

Etienne Desautels

unread,
May 4, 2012, 1:49:15 PM5/4/12
to django-...@googlegroups.com
> That's a wrong setting in the "sites" table, make sure the entry with the SITE_ID does indeed match what it should be.

Oh, yeah, corrected and it works now.

Thanks again.

Etienne
Reply all
Reply to author
Forward
0 new messages