Table Of ContentG
BOOKS FOR PROFESSIONALS BY PROFESSIONALS® e THE EXPERT’S VOICE® IN OPEN SOURCE
o
r
g
e
B
Beginning django CMS e
g
i
n
Beginning
Build a world-class website in less than a week with django CMS. Beginning django n
i
CMS shows you how to simply and easily write a dynamic website with a full n
g
content management system in the backend. It is written for Internet developers
d
who are sick and tired of dealing with complicated, bloated website frameworks j
a
that are a pain to build and a nightmare to maintain. django CMS is an Open Source n
website-building framework that is experiencing exponential growth because it is g django CMS
o
built on the simple, secure, and scalable architecture of Django. This book takes
C
you from knowing nothing about django CMS, to building a functional website and M
content management system that you can deploy for your own website or for your
S
customers.
What You’ll Learn:
• Install and confi gure django CMS Build a fi rst-class content
• Build a dynamic website quickly and easily
• Author and submit content for publication management system from
• Administer django CMS
• Install and use custom and third-party plugins
the ground up the easy way
• Deploy a website using django CMS
—
Nigel George
Foreword by Daniele Procida from Divio,
the company behind django CMS
Shelve in:
ISBN 978-1-4842-1670-5
52999 Web Development/General
User level:
Beginning–Intermediate
9781484216705 SOURCE CODE ONLINE
www.apress.com
www.it-ebooks.info
Beginning
django CMS
Nigel George
www.it-ebooks.info
Beginning django CMS
Copyright © 2015 by Nigel George
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part
of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations,
recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission
or information storage and retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed. Exempted from this legal reservation are
brief excerpts in connection with reviews or scholarly analysis or material supplied specifically for
the purpose of being entered and executed on a computer system, for exclusive use by the purchaser
of the work. Duplication of this publication or parts thereof is permitted only under the provisions
of the Copyright Law of the Publisher’s location, in its current version, and permission for use must
always be obtained from Springer. Permissions for use may be obtained through RightsLink at the
Copyright Clearance Center. Violations are liable to prosecution under the respective Copyright Law.
ISBN-13 (pbk): 978-1-4842-1670-5
ISBN-13 (electronic): 978-1-4842-1669-9
Trademarked names, logos, and images may appear in this book. Rather than use a trademark
symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and
images only in an editorial fashion and to the benefit of the trademark owner, with no intention of
infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they
are not identified as such, is not to be taken as an expression of opinion as to whether or not they are
subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of
publication, neither the authors nor the editors nor the publisher can accept any legal responsibility
for any errors or omissions that may be made. The publisher makes no warranty, express or implied,
with respect to the material contained herein.
Managing Director: Welmoed Spahr
Lead Editor: Ben Renow-Clarke
Development Editor: James Markham
Technical Reviewer: Massimo Nardone
Editorial Board: Steve Anglin, Pramila Balen, Louise Corrigan, Jim DeWolf, Jonathan Gennick,
Robert Hutchinson, Celestin Suresh John, Michelle Lowman, James Markham,
Susan McDermott, Matthew Moodie, Jeffrey Pepper, Douglas Pundick, Ben Renow-Clarke,
Gwenan Spearing
Coordinating Editor: Melissa Maldonado
Copy Editor: James A. Compton
Compositor: SPi Global
Indexer: SPi Global
Artist: SPi Global
Distributed to the book trade worldwide by Springer Science+Business Media New York,
233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail
orders-ny@springer-sbm.com, or visit www.springer.com. Apress Media, LLC is a California LLC and
the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM
Finance Inc. is a Delaware corporation.
For information on translations, please e-mail rights@apress.com, or visit www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional
use. eBook versions and licenses are also available for most titles. For more information, reference
our Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales.
Any source code or other supplementary materials referenced by the author in this text is available
to readers at www.apress.com. For detailed information about how to locate your book’s source code,
go to www.apress.com/source-code/.
www.it-ebooks.info
To Kate, for always being there, and to my boys
—Chris and Zac.
You make me proud.
www.it-ebooks.info
Contents at a Glance
About the Author ����������������������������������������������������������������������������xiii
About the Technical Reviewer ���������������������������������������������������������xv
Foreword ���������������������������������������������������������������������������������������xvii
Acknowledgments ��������������������������������������������������������������������������xix
Introduction ������������������������������������������������������������������������������������xxi
■ Chapter 1: Working with a CMS ������������������������������������������������������1
■ Chapter 2: Installing django CMS ���������������������������������������������������7
■ Chapter 3: Introduction to django CMS ����������������������������������������17
■ Chapter 4: Site Templates �������������������������������������������������������������25
■ Chapter 5: Your Blog Website: Templates �������������������������������������45
■ Chapter 6: django CMS Plugins ����������������������������������������������������61
■ Chapter 7: Advanced Plugins �������������������������������������������������������79
■ Chapter 8: Authoring in django CMS ��������������������������������������������97
■ Chapter 9: Menus and Navigation ����������������������������������������������125
■ Chapter 10: Extending django CMS ��������������������������������������������141
■ Chapter 11: Next Steps ���������������������������������������������������������������167
Index ����������������������������������������������������������������������������������������������173
v
www.it-ebooks.info
Contents
About the Author ����������������������������������������������������������������������������xiii
About the Technical Reviewer ���������������������������������������������������������xv
Foreword ���������������������������������������������������������������������������������������xvii
Acknowledgments ��������������������������������������������������������������������������xix
Introduction ������������������������������������������������������������������������������������xxi
■ Chapter 1: Working with a CMS ������������������������������������������������������1
A Brief History �����������������������������������������������������������������������������������������1
Content Management 101 �����������������������������������������������������������������������2
Content Management Roles �������������������������������������������������������������������������������������2
Anatomy of a Modern CMS ����������������������������������������������������������������������3
What You Will Learn ���������������������������������������������������������������������������������4
Summary �������������������������������������������������������������������������������������������������5
■ Chapter 2: Installing django CMS ���������������������������������������������������7
Installing Python ��������������������������������������������������������������������������������������8
Check Whether Python Is Installed ���������������������������������������������������������������������������8
Download and Install Python ����������������������������������������������������������������������������������10
Installing a Python Virtual Environment �������������������������������������������������12
Installing django CMS����������������������������������������������������������������������������13
Summary �����������������������������������������������������������������������������������������������16
vii
www.it-ebooks.info
■ Contents
■ Chapter 3: Introduction to django CMS ����������������������������������������17
Design Philosophy ���������������������������������������������������������������������������������17
The Structure of django CMS ����������������������������������������������������������������19
The django CMS Toolbar �����������������������������������������������������������������������������������������21
The django CMS Side Pane �������������������������������������������������������������������������������������22
django CMS for Designers and Developers �������������������������������������������22
Summary �����������������������������������������������������������������������������������������������23
■ Chapter 4: Site Templates �������������������������������������������������������������25
Django Templates 101 ���������������������������������������������������������������������������25
Inheritance ��������������������������������������������������������������������������������������������������������������25
Separation of Logic and Presentation ���������������������������������������������������������������������27
Extensibility ������������������������������������������������������������������������������������������������������������30
Bootstrap �����������������������������������������������������������������������������������������������36
The Bootstrap Grid System �������������������������������������������������������������������������������������37
Bootstrap CSS Classes �������������������������������������������������������������������������������������������39
Bootstrap Components �������������������������������������������������������������������������������������������40
Tying it all Together �������������������������������������������������������������������������������41
Summary �����������������������������������������������������������������������������������������������44
■ Chapter 5: Your Blog Website: Templates �������������������������������������45
Create a Clean Install ����������������������������������������������������������������������������45
Create Your Base Template ��������������������������������������������������������������������50
Create Your Blog Templates �������������������������������������������������������������������56
Summary �����������������������������������������������������������������������������������������������59
viii
www.it-ebooks.info
■ Contents
■ Chapter 6: django CMS Plugins ����������������������������������������������������61
Getting Started ��������������������������������������������������������������������������������������61
Default Plugins ��������������������������������������������������������������������������������������63
Installing the Default Plugins ����������������������������������������������������������������������������������63
The Text Plugin �������������������������������������������������������������������������������������������������������64
The Link Plugin �������������������������������������������������������������������������������������������������������66
The Picture Plugin ��������������������������������������������������������������������������������������������������68
The File Plugin ��������������������������������������������������������������������������������������������������������70
The Video Plugin �����������������������������������������������������������������������������������������������������70
The Multi Columns Plugin ���������������������������������������������������������������������������������������72
The Style Plugin ������������������������������������������������������������������������������������������������������72
The Teaser Plugin ���������������������������������������������������������������������������������������������������74
The Flash Plugin �����������������������������������������������������������������������������������������������������76
The Google Map Plugin �������������������������������������������������������������������������������������������76
The Create Alias Plugin �������������������������������������������������������������������������������������������77
Summary �����������������������������������������������������������������������������������������������78
■ Chapter 7: Advanced Plugins �������������������������������������������������������79
Easy Thumbnails �����������������������������������������������������������������������������������79
CMSplugin-filer �������������������������������������������������������������������������������������82
File Manager �����������������������������������������������������������������������������������������������������������85
The File Plugin ��������������������������������������������������������������������������������������������������������86
The Folder Plugin ����������������������������������������������������������������������������������������������������86
The Image Plugin ����������������������������������������������������������������������������������������������������87
The Link Plugin �������������������������������������������������������������������������������������������������������89
The Teaser Plugin ���������������������������������������������������������������������������������������������������90
The Video Plugin �����������������������������������������������������������������������������������������������������91
ix
www.it-ebooks.info
■ Contents
djangocms-forms ����������������������������������������������������������������������������������91
Creating a Form ������������������������������������������������������������������������������������������������������94
Adding Form Fields �������������������������������������������������������������������������������������������������94
Form Administration �����������������������������������������������������������������������������������������������96
Summary �����������������������������������������������������������������������������������������������96
■ Chapter 8: Authoring in django CMS ��������������������������������������������97
The django CMS Toolbar ������������������������������������������������������������������������97
Site Root (example�com) �����������������������������������������������������������������������������������������97
Page ������������������������������������������������������������������������������������������������������������������������99
Add Page ��������������������������������������������������������������������������������������������������������������100
Page Settings �������������������������������������������������������������������������������������������������������101
Templates �������������������������������������������������������������������������������������������������������������101
Advances Settings ������������������������������������������������������������������������������������������������101
Permissions ����������������������������������������������������������������������������������������������������������102
Publishing Dates ���������������������������������������������������������������������������������������������������104
Hide in Navigation ������������������������������������������������������������������������������������������������105
Publish/Unpublish Page ����������������������������������������������������������������������������������������105
Delete Page ����������������������������������������������������������������������������������������������������������105
Save as Page Type ������������������������������������������������������������������������������������������������105
History ������������������������������������������������������������������������������������������������������������������106
Toolbar Buttons �����������������������������������������������������������������������������������������������������107
Adding Content to Your Site �����������������������������������������������������������������108
django CMS Administration �����������������������������������������������������������������113
Page Administration ���������������������������������������������������������������������������������������������114
User Management ������������������������������������������������������������������������������������������������116
Authorization and User Permissions ���������������������������������������������������������������������117
Summary ���������������������������������������������������������������������������������������������123
x
www.it-ebooks.info
■ Contents
■ Chapter 9: Menus and Navigation ����������������������������������������������125
Customizing the Menu�������������������������������������������������������������������������125
Creating a Custom Menu ��������������������������������������������������������������������������������������126
Breadcrumbs ���������������������������������������������������������������������������������������132
Social Buttons �������������������������������������������������������������������������������������134
Sitemaps ���������������������������������������������������������������������������������������������138
Summary ���������������������������������������������������������������������������������������������140
■ Chapter 10: Extending django CMS ��������������������������������������������141
Extending the Page and Title Models ��������������������������������������������������141
Create the Models ������������������������������������������������������������������������������������������������142
Register Models with Django Admin ���������������������������������������������������������������������143
Create the Toolbar Item ����������������������������������������������������������������������������������������144
Add Category to Your Pages ���������������������������������������������������������������������������������146
Apps and Apphooks �����������������������������������������������������������������������������146
Apphooks ��������������������������������������������������������������������������������������������������������������149
Extending the Toolbar ��������������������������������������������������������������������������151
Custom Plugins �����������������������������������������������������������������������������������155
Sidebar Navigation ������������������������������������������������������������������������������156
Before You Start ����������������������������������������������������������������������������������������������������156
Create the Plugin Publisher ����������������������������������������������������������������������������������157
Create the Plugin Template �����������������������������������������������������������������������������������160
Add Placeholder to Page Template �����������������������������������������������������������������������161
Add Configuration Options to Your Plugin �������������������������������������������������������������163
Summary ���������������������������������������������������������������������������������������������166
xi
www.it-ebooks.info