Django MEZZANINE Blog Setup

In the previous post, I wrote how to set up django zinnia blog.
However, django-zinnia-blog documentation is not really intended for django beginners and you have read the source to know how it works.
I only know the basic, I could not properly override urls and templates, because it seemed django-zinnia-blog apps depend on each other and it was difficult to just deploy the app I want from it.
Mezzanine is a CMS but has a blog functionality as well. And most importantly it has very rich documentation. It's got even FAQ! It also explains how to override templates.:) I think it comes with caching functionality, too because it performs a lot faster than zinnia with demo setup.
A following note is how to have mezzaine running on arch linux with nginx and postgresql and uwsgi. I choose arch linux, because it is the simplest distribution I know and it's bleeding edge which I think makes the OS more secure. Systemd works wonderfully as well. Nginx and postgresql are chosen just because I feel they are a lot lighter than other alternatives. I alway choose uwsgi because it is simple enough and people say it performs the best among python application servers.

1. Nesessary packages. (from Arch linux repository and pip)
pacman -S python-pip libjpeg-turbo gcc nginx postgresql
pip install mezzanine
pip install uwsgi

2. DB (btrfs)
su - postgres
initdb --locale en_GB.UTF-8 -E UTF8 -D '/var/lib/postgres/data/'
chattr +C /var/lib/postgres/data

su -
systemctl start postgresql
systemctl enable postgresql

su - postgres
createuser --interactive
createdb myblogdb


3. uwsgi
mkdir -p /etc/uwsgi/vassals

vim /etc/uwsgi/emperor.ini
emperor = /etc/uwsgi/vassals
uid = http
gid = http

vim /etc/systemd/system/emperor.uwsgi.service
Description=uWSGI Emperor

ExecStart=/usr/bin/uwsgi --ini /etc/uwsgi/emperor.ini
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/bin/kill -INT $MAINPID


mkdir /opt/mezzanine
cd /opt/mezzanine
mezzanine-project myblog
cd myblog

vim myblog/

    'default': {
    'ENGINE': 'django.db.backends.postgresql',
    'NAME': 'myblogdb',
    'USER': 'root',
    'HOST': 'localhost',
    'PORT': '5432',

cp -p /usr/lib/python3.5/site-packages/mezzanine/utils/ /usr/lib/python3.5/site-packages/mezzanine/utils/

vim /usr/lib/python3.5/site-packages/mezzanine/utils/
remove ,HTMLParseError from the forth line.

mkdir -p static/media
python collectstatic
python migrate

5. nginx conf for mezzanine. (Example. I recommend going full ssl.)
vim /opt/mezzanine/myblog/myblog_nginx.conf
upstream django {

server {
    listen 80;
    charset utf-8;

    location /static {
        alias /opt/mezzanine/myblog/static;

    location / {
        uwsgi_pass django;
        include /etc/nginx/uwsgi_params;

mkdir /etc/nginx/sites-enabled/
ln -s /opt/mezzanine/myblog/myblog_nginx.conf /etc/nginx/sites-enabled/

6. uwsgi conf for mezzanine

vim /opt/mezzanine/myblog/myblog_uwsgi.ini
chdir = /opt/mezzanine/myblog/
module = myblog.wsgi
master = true
processes = 4
socket =

ln -s /opt/mezzanine/myblog/myblog_uwsgi.ini /etc/uwsgi/vassals/

7. http directive main nginx conf.
vim /etc/nginx/nginx.conf
include /etc/nginx/sites-enabled/*;

8. change to
DEBUG = False

9. Create admin user for the django project, resync the db just in case.
python createsuperuser
python migrate

10. start service
systemctl restart nginx
systemctl restart postgresql
systemctl restart emperor.uwsgi
systemctl reenable nginx
systemctl reenable postgresql
systemctl reenable emperor.uwsgi

Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: