Skip to content

Provide an AbstractPage model for multiple specialised Page models #241

@wouterter

Description

@wouterter

For our clients in the past and present there's a need to administer multiple websites in the same admin. There's usually a lot of content shared between sites. But not every site has the same Page requirements. One Page model with several root page trees for every site is not the way to go when those sites are so different. We needed the ability to create multiple separate Page models with different extensions per site.

Back in 2010, my colleague discussed this issue on the group: http://groups.google.com/group/django-feincms/browse_thread/thread/3d1d74f0169665af/c366f18ca5d15ff8?lnk=gst&q=matthijs#c366f18ca5d15ff8

This is something we've already accomplished in a very dirty way. For every website in the same Django project we created an app, with the following code in models.py:

import inspect
from feincms.module.page import models

# Clone FeinCMS Page module code and make it our own.
# Warning: dirty hack, but no other way around it;
# We want to have a seperate table for each website we
# manage in the CMS, but since feincms provides a
# concrete Page modelclass, we cant override it, because
# Django's model inheritance would just point to one Page
# table where all pages from all CMS'es would be stored.
# Also per website we want to register custom extensions,
# these should not be shared. The only way to practically
# achieve this currently, is by faking that the
# Page model lives in the modulespace for a website. 
exec(inspect.getsource(models))
Page.register_extensions('our', 'custom', 'extensions', 'for', 'this', 'website_page')

Also, some functionality of FeinCMS is hardwired to The One Page model, such as template tags, ApplicationContent view reversal, and of course the view handler. We've managed to monkey patch these dependencies, so every website can communicate with its own Page model.

But it's fair to say that this could be way more elegant by providing this flexibility from upstream.

Thanks!

Wouter

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions