SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Mezzanine簡介
@Taichung.py meetup
Max Lai
2016/6/11
講者介紹
• Max Lai
• Taichung.py 共同發起人
• Agile.Taichung 共同發起人
• 專長是電腦視覺, 敏捷開發
• 喜歡用 python 實作一些自己side project
大綱
• Mezzanine簡介
• 快速Mezzanine 網站架設
• 內容架構及管理
• 客製化內容頁面
• 如何佈署到 pythonanywhere PaaS平台
What is CMS
• Content Management System
• PHP:
• Wordpress
• Drupal
• Joomla
• Python
• Mezzanine
• DjangoCMS
• Wagtail
• AN OPEN SOURCE CONTENT
MANAGEMENT PLATFORM BUILT
USING THE DJANGO FRAMEWORK
• BSD Licensed. It can be freely used,
modified, and redistributed commercially.
MEZZANINE
Mezzanine簡介
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.
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
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)
Extra Batteries Included
• Ecommerce: catridge.jupo.org
• Forum: drum.jupo.org
• Themes: mezzathe.me
• ~70 Packages:
https://www.djangopackages.com/grids/g/mezzanine/
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
Live demo
• 一般用戶
• 內容管理者
• content creator user guide
• http://www.solutionm.co.nz/static/media/uploads/Mezzanine%20CMS%
20Guide.pdf
“Mantra for working with
Mezzanine:
Mezzanine is Just Django”
Ken Bolton, long-time Mezzanine contributor.
第一個 App
建立客製的內容型別
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
建立客製的內容型別
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
建立客製的內容型別
Creating Custom Content Types
{% extends "pages/page.html" %}
{% load mezzanine_tags %}
{% block main %}
{{ block.super }}
<h1>{{ page.author.title }}</h1>
<p>{{ page.author.dob }}</p>
{% for book in page.author.book_set.all %}
<img src="{{ MEDIA_URL }}{{ book.cover }}">
{% endfor %}
{% endblock %}
templates/pages/author.html建立 template
INSTALLED_APPS = (
"django.contrib.admin",
…
"books",
)
settings.py taichung/settings.py
http://goo.gl/J7iDaI
第二個 App
建立客製的內容型別
Creating Custom Content Types
from django.db import models
from mezzanine.pages.models import Page
# Poll 繼承 Page model.
# 利用 title field 儲存poll 的題目
# 增加一個 data field: pub_date
class Poll(Page):
pub_date = models.DateTimeField("Date published")
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
$ python manage.py startapp poll poll/models.py
建立客製的內容型別
Creating Custom Content Types
from copy import deepcopy
from django.contrib import admin
from mezzanine.core.admin import TabularDynamicInlineAdmin
from mezzanine.pages.admin import PageAdmin
from .models import Poll, Choice
poll_extra_fieldsets = ((None, {"fields": ("pub_date",)}),)
class ChoiceInline(TabularDynamicInlineAdmin):
model = Choice
class PollAdmin(PageAdmin):
inlines = (ChoiceInline,)
fieldsets = (deepcopy(PageAdmin.fieldsets) + poll_extra_fieldsets)
admin.site.register(Poll, PollAdmin)
poll/admin.py註冊 model 到 Django’s Admin
建立客製的內容型別
Creating Custom Content Types
{% extends "pages/page.html" %}
{% load mezzanine_tags %}
{% block title %}
{% editable page.poll.title %}{{ page.poll.title }}{% endeditable %}
{% endblock %}
{% block main %}
{{ block.super }}
<p>Published at {{ page.poll.pub_date }}</p>
<ul>
{% for choice in page.poll.choice_set.all %}
<li><b>{{ choice.choice_text }}</b> votes: <span
class="badge">{{ choice.votes }}</span></li>
{% endfor %}
</ul>
{% endblock %}
poll/templates/pages/poll.html建立 template
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.
建立客製的內容型別
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
建立客製的內容型別
Page Processor
<h2>Vote!!!</h2>
{% if error_message %}<div class="alert alert-
danger">{{ error_message }}</div>{% endif %}
{% if success_message %}<div class="alert alert-
success">{{ success_message }}</div>{% endif %}
<form action="." method="post">
{% csrf_token %}
{% for choice in page.poll.choice_set.all %}
<input type="radio" name="choice" id="choice{{ forloop.counter }}"
value="{{ choice.id }}" />
<label
for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label><br />
{% endfor %}
<input type="submit" value="Vote" />
</form>
Poll.html poll/template/pages/poll.html
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
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/
More information?
• Documentation
• http://mezzanine.jupo.org/
• Stephen McDonald’s PyCon APAC keynote http://goo.gl/fpqrD3
• Source Code
• https://github.com/stephenmcd/mezzanine
• Mailing list
• https://groups.google.com/forum/#!forum/mezzanine-users
• 本次 demo 範例檔
• https://drive.google.com/open?id=0BxXb4EAVtZX-
S2NqVmFVbG5rTGs

Weitere ähnliche Inhalte

Was ist angesagt?

The Truth About Your Web App's Performance
The Truth About Your Web App's PerformanceThe Truth About Your Web App's Performance
The Truth About Your Web App's PerformanceJohn Riviello
 
Oleh Zasadnyy "Progressive Web Apps: line between web and native apps become ...
Oleh Zasadnyy "Progressive Web Apps: line between web and native apps become ...Oleh Zasadnyy "Progressive Web Apps: line between web and native apps become ...
Oleh Zasadnyy "Progressive Web Apps: line between web and native apps become ...IT Event
 
Custom Elements with Polymer Web Components #econfpsu16
Custom Elements with Polymer Web Components #econfpsu16Custom Elements with Polymer Web Components #econfpsu16
Custom Elements with Polymer Web Components #econfpsu16John Riviello
 
Intro to jQuery @ Startup Institute
Intro to jQuery @ Startup InstituteIntro to jQuery @ Startup Institute
Intro to jQuery @ Startup InstituteRafael Gonzaque
 
Two scoops of django 1.6 - Ch7, Ch8
Two scoops of django 1.6  - Ch7, Ch8Two scoops of django 1.6  - Ch7, Ch8
Two scoops of django 1.6 - Ch7, Ch8flywindy
 
Google Developer Day 2010 Japan: 新 SocialWeb: 全てはオープンスタンダードの元に (ティモシー ジョーダン)
Google Developer Day 2010 Japan: 新 SocialWeb: 全てはオープンスタンダードの元に (ティモシー ジョーダン)Google Developer Day 2010 Japan: 新 SocialWeb: 全てはオープンスタンダードの元に (ティモシー ジョーダン)
Google Developer Day 2010 Japan: 新 SocialWeb: 全てはオープンスタンダードの元に (ティモシー ジョーダン)Google Developer Relations Team
 
On-page SEO for Drupal
On-page SEO for DrupalOn-page SEO for Drupal
On-page SEO for DrupalSvilen Sabev
 
Chrome enchanted 2015
Chrome enchanted 2015Chrome enchanted 2015
Chrome enchanted 2015Chang W. Doh
 
Polymer, A Web Component Polyfill Library
Polymer, A Web Component Polyfill LibraryPolymer, A Web Component Polyfill Library
Polymer, A Web Component Polyfill Librarynaohito maeda
 
Google Developer DAy 2010 Japan: HTML5 についての最新情報 (マイク スミス)
Google Developer DAy 2010 Japan: HTML5 についての最新情報 (マイク スミス)Google Developer DAy 2010 Japan: HTML5 についての最新情報 (マイク スミス)
Google Developer DAy 2010 Japan: HTML5 についての最新情報 (マイク スミス)Google Developer Relations Team
 
The Art of AngularJS in 2015
The Art of AngularJS in 2015The Art of AngularJS in 2015
The Art of AngularJS in 2015Matt Raible
 
Getting Started With Django
Getting Started With DjangoGetting Started With Django
Getting Started With Djangojeff_croft
 
Drupal security
Drupal securityDrupal security
Drupal securityJozef Toth
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2fishwarter
 

Was ist angesagt? (17)

End-to-end testing with geb
End-to-end testing with gebEnd-to-end testing with geb
End-to-end testing with geb
 
Google AJAX APIs
Google  AJAX APIsGoogle  AJAX APIs
Google AJAX APIs
 
The Truth About Your Web App's Performance
The Truth About Your Web App's PerformanceThe Truth About Your Web App's Performance
The Truth About Your Web App's Performance
 
Oleh Zasadnyy "Progressive Web Apps: line between web and native apps become ...
Oleh Zasadnyy "Progressive Web Apps: line between web and native apps become ...Oleh Zasadnyy "Progressive Web Apps: line between web and native apps become ...
Oleh Zasadnyy "Progressive Web Apps: line between web and native apps become ...
 
Custom Elements with Polymer Web Components #econfpsu16
Custom Elements with Polymer Web Components #econfpsu16Custom Elements with Polymer Web Components #econfpsu16
Custom Elements with Polymer Web Components #econfpsu16
 
Intro to jQuery @ Startup Institute
Intro to jQuery @ Startup InstituteIntro to jQuery @ Startup Institute
Intro to jQuery @ Startup Institute
 
Two scoops of django 1.6 - Ch7, Ch8
Two scoops of django 1.6  - Ch7, Ch8Two scoops of django 1.6  - Ch7, Ch8
Two scoops of django 1.6 - Ch7, Ch8
 
Google Developer Day 2010 Japan: 新 SocialWeb: 全てはオープンスタンダードの元に (ティモシー ジョーダン)
Google Developer Day 2010 Japan: 新 SocialWeb: 全てはオープンスタンダードの元に (ティモシー ジョーダン)Google Developer Day 2010 Japan: 新 SocialWeb: 全てはオープンスタンダードの元に (ティモシー ジョーダン)
Google Developer Day 2010 Japan: 新 SocialWeb: 全てはオープンスタンダードの元に (ティモシー ジョーダン)
 
On-page SEO for Drupal
On-page SEO for DrupalOn-page SEO for Drupal
On-page SEO for Drupal
 
Chrome enchanted 2015
Chrome enchanted 2015Chrome enchanted 2015
Chrome enchanted 2015
 
Polymer, A Web Component Polyfill Library
Polymer, A Web Component Polyfill LibraryPolymer, A Web Component Polyfill Library
Polymer, A Web Component Polyfill Library
 
Google Developer DAy 2010 Japan: HTML5 についての最新情報 (マイク スミス)
Google Developer DAy 2010 Japan: HTML5 についての最新情報 (マイク スミス)Google Developer DAy 2010 Japan: HTML5 についての最新情報 (マイク スミス)
Google Developer DAy 2010 Japan: HTML5 についての最新情報 (マイク スミス)
 
The Art of AngularJS in 2015
The Art of AngularJS in 2015The Art of AngularJS in 2015
The Art of AngularJS in 2015
 
Getting Started With Django
Getting Started With DjangoGetting Started With Django
Getting Started With Django
 
Apex & jQuery Mobile
Apex & jQuery MobileApex & jQuery Mobile
Apex & jQuery Mobile
 
Drupal security
Drupal securityDrupal security
Drupal security
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 

Ähnlich wie Build engaging websites with Mezzanine CMS

GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineYared Ayalew
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction DjangoWade Austin
 
django_introduction20141030
django_introduction20141030django_introduction20141030
django_introduction20141030Kevin Wu
 
Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Djangofool2nd
 
An Introduction to Django Web Framework
An Introduction to Django Web FrameworkAn Introduction to Django Web Framework
An Introduction to Django Web FrameworkDavid Gibbons
 
Django Overview
Django OverviewDjango Overview
Django OverviewBrian Tol
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django IntroductionGanga Ram
 
بررسی چارچوب جنگو
بررسی چارچوب جنگوبررسی چارچوب جنگو
بررسی چارچوب جنگوrailsbootcamp
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoJoaquim Rocha
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!David Gibbons
 
MongoDB hearts Django? (Django NYC)
MongoDB hearts Django? (Django NYC)MongoDB hearts Django? (Django NYC)
MongoDB hearts Django? (Django NYC)Mike Dirolf
 
國民雲端架構 Django + GAE
國民雲端架構 Django + GAE國民雲端架構 Django + GAE
國民雲端架構 Django + GAEWinston Chen
 
Web development with django - Basics Presentation
Web development with django - Basics PresentationWeb development with django - Basics Presentation
Web development with django - Basics PresentationShrinath Shenoy
 
Writing automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjectsWriting automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjectsLeticia Rss
 
The Role of Python in SPAs (Single-Page Applications)
The Role of Python in SPAs (Single-Page Applications)The Role of Python in SPAs (Single-Page Applications)
The Role of Python in SPAs (Single-Page Applications)David Gibbons
 
Hdv309 - Real World Sandboxed Solutions
Hdv309 - Real World Sandboxed SolutionsHdv309 - Real World Sandboxed Solutions
Hdv309 - Real World Sandboxed Solutionswoutervugt
 

Ähnlich wie Build engaging websites with Mezzanine CMS (20)

GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction Django
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
django_introduction20141030
django_introduction20141030django_introduction20141030
django_introduction20141030
 
Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Django
 
An Introduction to Django Web Framework
An Introduction to Django Web FrameworkAn Introduction to Django Web Framework
An Introduction to Django Web Framework
 
Django Overview
Django OverviewDjango Overview
Django Overview
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django Introduction
 
بررسی چارچوب جنگو
بررسی چارچوب جنگوبررسی چارچوب جنگو
بررسی چارچوب جنگو
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Mini Curso de Django
Mini Curso de DjangoMini Curso de Django
Mini Curso de Django
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!
 
MongoDB hearts Django? (Django NYC)
MongoDB hearts Django? (Django NYC)MongoDB hearts Django? (Django NYC)
MongoDB hearts Django? (Django NYC)
 
Django at the Disco
Django at the DiscoDjango at the Disco
Django at the Disco
 
國民雲端架構 Django + GAE
國民雲端架構 Django + GAE國民雲端架構 Django + GAE
國民雲端架構 Django + GAE
 
Web development with django - Basics Presentation
Web development with django - Basics PresentationWeb development with django - Basics Presentation
Web development with django - Basics Presentation
 
Writing automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjectsWriting automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjects
 
The Role of Python in SPAs (Single-Page Applications)
The Role of Python in SPAs (Single-Page Applications)The Role of Python in SPAs (Single-Page Applications)
The Role of Python in SPAs (Single-Page Applications)
 
Web Scrapping Using Python
Web Scrapping Using PythonWeb Scrapping Using Python
Web Scrapping Using Python
 
Hdv309 - Real World Sandboxed Solutions
Hdv309 - Real World Sandboxed SolutionsHdv309 - Real World Sandboxed Solutions
Hdv309 - Real World Sandboxed Solutions
 

Kürzlich hochgeladen

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Kürzlich hochgeladen (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

Build engaging websites with Mezzanine CMS

  • 2. 講者介紹 • Max Lai • Taichung.py 共同發起人 • Agile.Taichung 共同發起人 • 專長是電腦視覺, 敏捷開發 • 喜歡用 python 實作一些自己side project
  • 3. 大綱 • Mezzanine簡介 • 快速Mezzanine 網站架設 • 內容架構及管理 • 客製化內容頁面 • 如何佈署到 pythonanywhere PaaS平台
  • 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
  • 17. 建立客製的內容型別 Creating Custom Content Types {% extends "pages/page.html" %} {% load mezzanine_tags %} {% block main %} {{ block.super }} <h1>{{ page.author.title }}</h1> <p>{{ page.author.dob }}</p> {% for book in page.author.book_set.all %} <img src="{{ MEDIA_URL }}{{ book.cover }}"> {% endfor %} {% endblock %} templates/pages/author.html建立 template INSTALLED_APPS = ( "django.contrib.admin", … "books", ) settings.py taichung/settings.py http://goo.gl/J7iDaI
  • 19. 建立客製的內容型別 Creating Custom Content Types from django.db import models from mezzanine.pages.models import Page # Poll 繼承 Page model. # 利用 title field 儲存poll 的題目 # 增加一個 data field: pub_date class Poll(Page): pub_date = models.DateTimeField("Date published") class Choice(models.Model): poll = models.ForeignKey(Poll) choice_text = models.CharField(max_length=200) votes = models.IntegerField(default=0) $ python manage.py startapp poll poll/models.py
  • 20. 建立客製的內容型別 Creating Custom Content Types from copy import deepcopy from django.contrib import admin from mezzanine.core.admin import TabularDynamicInlineAdmin from mezzanine.pages.admin import PageAdmin from .models import Poll, Choice poll_extra_fieldsets = ((None, {"fields": ("pub_date",)}),) class ChoiceInline(TabularDynamicInlineAdmin): model = Choice class PollAdmin(PageAdmin): inlines = (ChoiceInline,) fieldsets = (deepcopy(PageAdmin.fieldsets) + poll_extra_fieldsets) admin.site.register(Poll, PollAdmin) poll/admin.py註冊 model 到 Django’s Admin
  • 21. 建立客製的內容型別 Creating Custom Content Types {% extends "pages/page.html" %} {% load mezzanine_tags %} {% block title %} {% editable page.poll.title %}{{ page.poll.title }}{% endeditable %} {% endblock %} {% block main %} {{ block.super }} <p>Published at {{ page.poll.pub_date }}</p> <ul> {% for choice in page.poll.choice_set.all %} <li><b>{{ choice.choice_text }}</b> votes: <span class="badge">{{ choice.votes }}</span></li> {% endfor %} </ul> {% endblock %} poll/templates/pages/poll.html建立 template
  • 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
  • 24. 建立客製的內容型別 Page Processor <h2>Vote!!!</h2> {% if error_message %}<div class="alert alert- danger">{{ error_message }}</div>{% endif %} {% if success_message %}<div class="alert alert- success">{{ success_message }}</div>{% endif %} <form action="." method="post"> {% csrf_token %} {% for choice in page.poll.choice_set.all %} <input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}" /> <label for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label><br /> {% endfor %} <input type="submit" value="Vote" /> </form> Poll.html poll/template/pages/poll.html
  • 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/
  • 27. More information? • Documentation • http://mezzanine.jupo.org/ • Stephen McDonald’s PyCon APAC keynote http://goo.gl/fpqrD3 • Source Code • https://github.com/stephenmcd/mezzanine • Mailing list • https://groups.google.com/forum/#!forum/mezzanine-users • 本次 demo 範例檔 • https://drive.google.com/open?id=0BxXb4EAVtZX- S2NqVmFVbG5rTGs