FeinCMS provides three ModelAdmin classes, ItemEditor, TreeEditor and SplitPaneEditor. Their purpose and their customization hooks are briefly discussed here.
The tree editor replaces the standard change list interface with a collapsible, item tree. The model must be registered with django-mptt for this to work.
Usage is as follows:
from django.db import models
class YourModel(models.Model):
# model field definitions
class Meta:
ordering = ['tree_id', 'lft'] # The TreeEditor needs this ordering definition
And inside your admin.py file:
from django.contrib import admin
from feincms.admin import editor
from yourapp.models import YourModel
class YourModelAdmin(editor.TreeEditor):
pass
admin.site.register(YourModel, YourModelAdmin)
All standard ModelAdmin attributes such as ModelAdmin.list_display, ModelAdmin.list_editable, ModelAdmin.list_filter work as normally. The only exception to this rule is the column showing the tree structure (the second column in the image). There, we always show the value of Model.__unicode__ currently.
The tree editor allows you to define boolean columns which let the website administrator change the value of the boolean using a simple click on the icon. These boolean columns can be aware of the tree structure. If f.e. an objects’ active-flag influences the state of its descendants, the tree editor interface is able to show not only the state of the modified element, but also the state of all its descendants without having to reload the page.
Currently, documentation for this feature is not available yet. You can take a look at the implementation of the is_visible and in_navigation columns of the page editor however.
Usage:
from django.contrib import admin
from feincms.admin import editor
import mptt
class Category(models.Model):
active = models.BooleanField()
name = models.CharField(...)
parent = models.ForeignKey('self', blank=True, null=True)
# ...
mptt.register(Category)
class CategoryAdmin(editor.TreeEditor):
list_display = ('__unicode__', 'active_toggle')
active_toggle = editor.ajax_editable_boolean('active', _('active'))
The item editor replaces the edit view (NOT the add form, therefore you may still use fieldsets, etc. to customize the form which is used to add new items.
The most important fields are shown beneath the submit bar at the top of the administration page, the tabbed interface below is used to edit content and other properties of the edited object. A tab is shown for every region of the template or element, depending on whether templates are activated for the object in question [1].
Here’s an screenshot of a content editing pane. The media file content is collapsed currently. New items can be added using the control bar at the bottom, and all content blocks can be reordered using drag and drop:
The last tab is always the properties pane. Additional information concerning the currently edited object can be shown and modified there:
| [1] | Templates are required for the page module; blog entries managed through the item editor probably wont have a use for them. |
show_on_top
A tuple which describes, which fields should be shown above the tabbed item editor interface.
Customizing the individual content type editors is easily possible through two settings on the content type model itself:
feincms_item_editor_context_processors:
A list of callables using which you may add additional values to the item editor templates.
feincms_item_editor_form:
You can specify the base class which should be used for the content type model. The default value is django.forms.ModelForm.
feincms_item_editor_includes:
If you need additional javascript or CSS files or need to perform additional initialization on your content type forms, you can specify template fragments which are included in predefined places into the item editor.
If you need to execute additional javascript, f.e. add a TinyMCE instance, it is recommended to add the initialization functions to the contentblock_init_handlers array, because the initialization needs to be performed not only on page load, but also after drag-dropping a content block and after adding new content blocks. Take a look at the mediafile and richtext item editor include files to understand how this should be done.
The split pane editor replaces the change list with two frames, a draggable and collapsible tree on the left and arbitrary information on the right. The interface is somewhat inspired by other popular tools such as Typo3 or PHPMyAdmin, which offer a framed interface for editing content too.
The split pane editor does not modify the content on the right hand side in any way – it does not care whether you have standard django administration forms, an item editor or even preview functionality in the right hand side.
Currently the split pane editor does not offer any customization hooks.
Best advice here is taking a look at the files inside feincms/module/page/.