Django Alapage

Page management application for Django.

Contents:

Install

pip install django-alapage

Then migrate

INSTALLED_APPS = (
     #~ ...
     'ckeditor',
     'ckeditor_uploader',
     'reversion',
     'codemirror2',
     'alapage',
 )

In urls.py

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

urlpatterns += url(r'^', include('alapage.urls')),

You have to put alapage urls in last if you want to have your pages served from /

Create an uploads directory for Ckeditor:

mkdir static/uploads

Settings

ALAPAGE_CODE_MODE = False : to use the wysywig editor instead of the code editor

ALAPAGE_BASE_TEMPLATE_PATH = 'my_base_template.html' : to choose a root base template with a different name than the default base.html

To configure the Ckeditor interface:

CKEDITOR_UPLOAD_PATH = 'uploads/'
CKEDITOR_JQUERY_URL = '/static/js/jquery-2.1.4.min.js'
CKEDITOR_IMAGE_BACKEND = 'pillow'
CKEDITOR_CONFIGS = {
    'default': {
        'toolbar':  [
                    ["Format", "Styles", "Bold", "Italic", "Underline", '-', 'RemoveFormat'],
                    ['NumberedList', 'BulletedList', "Indent", "Outdent", 'JustifyLeft', 'JustifyCenter','JustifyRight', 'JustifyBlock'],
                    ["Image", "Table", "Link", "Unlink", "Anchor", "SectionLink", "Subscript", "Superscript"], ['Undo', 'Redo'],
                    ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord'],["Source", "Maximize"],
                    ]
    },
    "removePlugins": "stylesheetparser",
    'width': '1150px',
    'height': '450px',
}

Templates

Blocks required by the default templates:

{% block content %} to display the main page content

{% block extra_head %} in the head tag to display SEO tags

{% block title %} in the head tag for the page title

Management commands

Create a homepage: python manage.py create_homepage

Create a page: python manage.py create_page 'Title' /url/

Populate pages with content:

# from string:
python manage.py populate_page "My content string"

# from file
python manage.py populate_page -f /my/file/path

Permissions management

Alapage provides page level permissions. Those with the can_change_page_permissions will be able to manage them.

Pages access can be limited to:

  • Logged in users
  • Staff
  • Groups
  • Users

Note: for the groups and users pages you have to check the checkbox before selecting a group or user (this is used internaly to avoid making a query when it is not strictly necessary to keep the things as fast and light as possible).

Inline edit

To edit pages inline use a block {% block editbtn %} in your main template: that will display an edit button.

The editor will be in fullscreen and hitting the save button will bring back the user to the online page.