A content management system (CMS) is an application that aims to help people with publishing contents of various types online … at least that’s what they’re supposed to do. With ever-so-popular and growing demand, most CMS applications have reached a point where they are even harder to use than crafting your own solution based on a framework.
Fortunately, there are a handful of brilliant exceptions to this rule – Mezzanine CMS is one of them.
Built on top of the powerful (and expandable) Django web framework, Mezzanine offers web-developers and online publishing enthusiasts alike a truly smooth ride from the very beginning with its extremely intuitive way of building websites.
In this DigitalOcean article, we are going to see how to prepare a brand new Ubuntu 13 cloud server to install and deploy a Mezzanine CMS based web-site from the absolute scratch. Continuing, we will see how to get started with this elegant library as we publish our first piece of content.
Django is a Python programming language based web-development framework. Being an extremely large project and library, it packs and ships tons of tools and features to developers who are looking forward to getting started quickly. If you are willing to spend a significant amount of time to “learn” a framework in order to save some in the future, Django for Python is probably the go-to solution.
Given their nature, powerful frameworks are not only helpful for creating custom applications or APIs but also packaged software, aiming to solve a specific set of problems. One of these custom software built on top of Django is the Mezzanine CMS.
Mezzanine - as we have mentioned - is a content management system built on top of the popular web-development framework Django. Although it requires some knowledge of Python programming language and a certain level of familiarity with Django, getting started using Mezzanine to create a web-site is much simpler than other content management tools and libraries, especially those based on other languages.
As a CMS, Mezzanine comes with a great amount of useful functionality that covers a majority of common needs that web-developers expect to get from such applications. Since Django is so easily expandable, Mezzanine is also surrounded with many additional third-party packages that can help you with shaping your web-site anyway you like as well. In fact, Mezzanine itself is an extension, or a Django application.
Here are some popular features of the Mezzanine CMS:
Drag-and-Drop (DaD) page ordering;
Theming via themes marketplace;
Account management and e-mail verification;
Easy social content sharing;
Mobile (e.g. smartphone, tablet etc.) friendly theming;
Disqus and Gravatar integration;
Built-in blogging engine;
Visual content editing;
Customising individual content types and their styles;
and much more.
Benefiting from expansion capabilities of Django, Mezzanine currently supports plenty of additional libraries and modules which aim to help developers with their various needs.
Some of these popular third-party modules are:
Widgets and filters to create and publish content using Markdown.
Theme collection for Django (thus Mezzanine).
Automatic captcha support for Mezzanine form builder.
Responsive slide display.
Calendar implementation for Mezzanine.
Easily adding individual background-images for Mezzanine pages.
Helps to manage twitter topics.
Recipe publishing plug-in.
Some Mezzanine modules allows the creation of complete web-application with unique features, such as an e-commerce web-site.
Some of these popular customisation modules are:
An online-shopping / e-commerce module.
A multi-user bookmarking application.
A polling application.
A job posting application.
A wiki solution.
Mezzanine is a Python project and you need to tune your system correctly in order to set up and run your web-site without glitches or errors.
If you haven’t got your droplet ready for this yet, head over quickly to our Ubuntu/Python article:
And continue with the Mezzanine installation instructions found below.
We are going to make use of the brilliant Python tool virtualenv in order to install and contain Mezzanine and its dependencies. Therefore, in this section, we are going to start with creating an environment.
If you haven’t already, create a virtual environment:
virtualenv mezzanine_env cd mezzanine_env
Or activate it:
Once we have our environment ready, we can use pip package manager to get Mezzanine and all the dependencies installed.
Run the following command to install Mezzanine using
pip install mezzanine
You may also need to install pillow
pip install pillow
Being a Django based tool, Mezzanine comes with Django-like features. One such item shipped with Mezzanine is
mezzanine-project which is used for administrative tasks.
Let’s get started working with Mezzanine.
Creating a new web-site with Mezzanine is as easy as running a single command:
# Usage: mezzanine-project [project name] # Example: mezzanine-project mezzanine_app # Enter the application directory: cd mezzanine_app
Mezzanine brings some additions to Django’s standard
manage.py management tool, such as the
Run the following to create and initiate a sample database:
python manage.py createdb
Once you execute this command, you will be asked a series of questions:
# You just installed Django's auth system, # which means you don't have any superusers defined. # Would you like to create one now? (yes/no): yes # ^^ Create an admin account by answering the questions. # Please enter the domain and optional port in # the format 'domain:port'. # For example 'localhost:8000' or 'www.example.com'. # Hit enter to use the default (127.0.0.1:8000): www.example.com:80 # ^^ Enter your domain name. # Would you like to install some initial demo pages? # Eg: About us, Contact form, Gallery. (yes/no): yes # ^^ Create sample data.
After having answered these questions, it is time to check out the application.
In order to avoid errors and do things the right way, although not strictly necessary, we need to perform certain configurations.
Let’s edit the
settings.py file using the
nano text editor:
Scroll down the file and find
ALLOWED_HOSTS = 
Replace it with:
# ALLOWED_HOSTS =  # comment out # Example (From Django documentation): ALLOWED_HOSTS = [ '.example.com', # Allow domain and subdomains '.example.com.', # Also allow FQDN and subdomains ] # Replace example.com with your own domain name.
Afterwards, go right below the block of comments and find:
And replace it with your own, e.g.:
TIME_ZONE = 'Europe/Amsterdam'
Save and exit by pressing CTRL+X and confirming with Y.
Run the following command to run a sample application server to check out your brand new Mezzanine application:
python manage.py runserver 0.0.0.0:8000
You can check out your installation by visiting your droplet on port 8000:
http://[your droplet's IP]:8000
Note: To terminate the test server, press CTRL+C.
Let’s publish some new content and see how easy it is to use Mezzanine.
Visit the admin section by going to:
http://[your droplet's IP]:8000/admin
Login with admin credentials you have set and press “Log In”.
You will see the Dashboard. From here, you can either publish a quick blogpost, or hover your cursor over the Content drop-down menu and choose any item you wish to edit, e.g.:
When you are finished creating your Mezzanine project, you should try to avoid relying on the testing server the application comes with.
For deployments, a fully-fledged web-application server (e.g. Unicorn) must be used, preferably behind a reverse-proxy that will handle the initial processing of requests and distribution of static files, such as images.
To get a quick overall idea of how to go to production, check out the section titles "Getting Ready For Production"on our article: How To Prepare Ubuntu Cloud Servers For Python Web-Applications.
If you have already been through this article once, or simply prefer a quick summary of installation instructions to get you started, check below:
# Preare the system and install Python tools: aptitude update aptitude -y upgrade aptitude install -y build-essential aptitude install -y cvs subversion git-core mercurial aptitude install python-setuptools python-dev python2.7-dev python-software-properties libpq-dev aptitude install libtiff4-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev curl https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | python - curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python - export PATH="/usr/local/bin:$PATH" pip install virtualenv # Create a virtual environment: virtualenv mezzanine_env cd mezzanine_env source bin/activate pip install mezzanine # Create a Mezzanine project: mezzanine-project mezzanine_app cd mezzanine_app python manage.py createdb --noinput # Run the testing server: python manage.py runserver 0.0.0.0:8000
Note: The last command
created using the
--noinput flag will allow you to initiate the database without being asked questions. Your admin username will be
admin, and your password
default. From hereon, you continue with configuring and testing.
<div class=“author”>Submitted by: <a href=“https://twitter.com/ostezer”>O.S. Tezer</a></div>
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.Sign up now
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
My answer based on experience would be yes, you want a virtual environment for each project. Let’s say you have two sites, mycoolsite.com and myawesomesite.com, both running on Mezzanine and including some custom modules that you built. One day, you upgrade Mezzanine to the latest version and one of the custom modules on mycoolsite.com breaks due to an incompatibility with the new version of Mezzanine. Now mycoolsite.com is broken until you figure out what’s wrong.
Virtual environments isolate the changes you make to a set of Python packages. If you use virtualenv, the packages (such as Mezzanine) are specific to one environment, and you can make changes to one environment without affecting the others. So in the example above, you would have two virtualenvs, one for each site. When you make a package change, like upgrading Mezzanine, you do so on each virtualenv individually. That means you could change the virtualenv for mycoolsite.com back to the previous version of Mezzanine and keep the site running while you worked out the kinks with the new version.
Virtual environments do take a little getting used to, but I’ve found them to be incredibly helpful. Google around, there are some very good tutorials on how to use them effectively.
Can someone please update this? There have been a number of changes and this guide is incomplete. It references gunicorn when fabric is now used, and the gunicorn article is actually not helpful because it doesn’t say how to point wsgi to a deployed Mezzanine.
Thanks again for this tutorial my project is up and running on the server but when I visit .myip:8000 I get a “webpage not available” error while the django_project installed from a one click installation is still running on my IP. Before I attempt to deploy I’d like to know what the issue is. I see that the tutorial is over a year old and followed verbatim lead me to this. Any help would be greatly appreciated.
So I have setup my droplet for python/Django. I have a virtualenv setup at /opt/myenv/. Do I need to create multiple virtual environments for each python project? I am trying to setup mezzanine now that I have python setup. What if I want to add more python projects later?