4. What is CMS
• Content Management System
• PHP:
• Wordpress
• Drupal
• Joomla
• Python
• Mezzanine
• DjangoCMS
• Wagtail
5. • AN OPEN SOURCE CONTENT
MANAGEMENT PLATFORM BUILT
USING THE DJANGO FRAMEWORK
• BSD Licensed. It can be freely used,
modified, and redistributed commercially.
MEZZANINE
Mezzanine簡介
6. Mezzanine簡介
• Mezzanine is a powerful, consistent, and flexible content
management platform.
• Built using the Django framework,
• Mezzanine provides a simple yet highly extensible architecture
that encourages diving in and hacking on the code.
• Mezzanine is BSD licensed and supported by a diverse and
active community.
• In some ways, Mezzanine resembles tools such as Wordpress,
providing an intuitive interface for managing pages, blog posts,
form data, store products, and other types of content.
7. USERS LOVE
• Hierarchical page navigation
• Save as draft and preview on site
• Scheduled publishing
• Drag-and-drop page ordering
• WYSIWYG editing
• In-line page editing
• Drag-and-drop HTML5 forms builder with
CSV export
• SEO friendly URLs and meta data
• Ecommerce / Shopping cart module
(Cartridge)
• Configurable dashboard widgets
• Blog engine
• Tagging
• Free Themes, and a Premium Themes
Marketplace
• User accounts and profiles with email
verification
• Translated to over 35 languages
• Sharing via Facebook or Twitter
• Multi-lingual sites
8. DEVELOPERS LOVE
• Custom templates per page or blog post
• Twitter Bootstrap integration
• API for custom content types
• Search engine and API
• Seamless integration with third-party
Django apps
• Multi-device detection and template
handling
• One step migration from other blogging
engines
• Automated production provisioning and
deployments
• Disqus integration, or built-in threaded
comments
• Gravatar integration
• Google Analytics integration
• Twitter feed integration
• bit.ly integration
• Akismet spam filtering
• Built-in test suite
• JVM compatible (via Jython)
9. Extra Batteries Included
• Ecommerce: catridge.jupo.org
• Forum: drum.jupo.org
• Themes: mezzathe.me
• ~70 Packages:
https://www.djangopackages.com/grids/g/mezzanine/
10. Quick Start
# Install from PyPI
$ pip install mezzanine
# Create a project
$ mezzanine-project taichung
$ cd taichung
# Create a database
$ python manage.py createdb
# Run the web server
$ python manage.py runserver
settings.py
TIME_ZONE = 'Asia/Taipei'
USE_TZ = True
LANGUAGE_CODE = "zh-tw"
LANGUAGES = (
('zh-tw', ('繁體中文')),
)
USE_I18N = True
11.
12. Live demo
• 一般用戶
• 內容管理者
• content creator user guide
• http://www.solutionm.co.nz/static/media/uploads/Mezzanine%20CMS%
20Guide.pdf
13. “Mantra for working with
Mezzanine:
Mezzanine is Just Django”
Ken Bolton, long-time Mezzanine contributor.
15. 建立客製的內容型別
Creating Custom Content Types
from django.db import models
from mezzanine.pages.models import Page
# Auther model 繼承 Page , 利用 title field 儲存 author’s name
# 增加額外的欄位 “Date of birth” (生日)
class Author(Page):
dob = models.DateField("Date of birth")
class Book(models.Model):
author = models.ForeignKey("Author")
cover = models.ImageField(upload_to="authors")
$ python manage.py startapp book book/models.py
http://goo.gl/EUJqjU
16. 建立客製的內容型別
Creating Custom Content Types
from django.contrib import admin
from mezzanine.pages.admin import PageAdmin
from .models import Author
admin.site.register(Author, PageAdmin)
book/admin.py註冊 model 到 Django’s Admin
http://goo.gl/EUJqjU
22. Page Processor
• Since every Page instance is handled via the view function
mezzanine.pages.views.page()
• We can’t create our own views for pages.
• Mezzanine solves this problem using Page Processors.
• Page Processors are simply functions that can be associated to
• any custom Page models and
• are called inside the mezzanine.pages.views.page() view
• input argument: the request and the Page instance
• returns:
• a dictionary ( to be added to the template context)
• Django’s HttpResponse classes (to override mezzanine.pages.views.page() view
entirely.
23. 建立客製的內容型別
Page Processor
from django.shortcuts import get_object_or_404
from mezzanine.pages.page_processors import processor_for
from .models import Poll, Choice
@processor_for(Poll)
def poll_form(request, page):
if request.method == "POST":
p = get_object_or_404(Poll, pk=page.poll.id)
try:
selected_choice = p.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
return {'error_message': "You didn't select a choice."}
else:
selected_choice.votes += 1
selected_choice.save()
return {'success_message': "Thank you for your vote."}
polls/page_processors.py建立 poll
25. Template
• Download themes
• https://github.com/thecodinghouse/mezzanine-themes
• Install a theme
• http://goo.gl/qz921c
• create a Django app with templates and static directories
• copy the relevant HTML, CSS and JavaScript files into it
• add the theme app’s name to your project’s INSTALLED_APPS setting
• Create Themes
• http://goo.gl/Caqqra
26. PythonAnywhere
• How to get your code in and out of PythonAnywhere
• https://help.pythonanywhere.com/pages/FTP/
• How to use Mezzanine on PythonAnywhere
• https://goo.gl/56Kakv
• Git push deployments on PythonAnywhere
• https://blog.pythonanywhere.com/87/