Mezzanine Local Test Environment



This is a tutorial to setup mezzanine local dev environment. If you have created website using mezzanine or even django and have had hair pulling experience with setting up a local dev environment then continue reading.

Here I will assume:

1) You know Git (I will skip setting up git repo)

2) You know basics of Mezzanine or Django

The Setup:

Okay so you already have a mezzanine website running on a VPS or a dedicated server running inside a virtualenv. Somehow you have managed to get it up and running. Now you have decided how to setup a local dev environment where you can make some changes and push them to production via git. Here is how you do it.

How To:


Create a virtualenv on your local machine .Git repo should be your project directory . Clone your repo  inside the virutalenv you just created. If you maintain a requirements.txt file, then activate the virtualenv and install pacakages from there like this

$ cd my_venv/
$ pip install -r requirements.txt

If you dont have a requirements.txt file then simply 

$ pip install mezzanine


Editing templates and pushing them to production is a straightforward thing.


A default mezzanine project looks like this

$ ls -alF proj

total 72
drwxrwxr-x  4 mayur mayur  4096 Oct 18 20:09 ./
drwxrwxr-x 11 mayur mayur  4096 Oct 18 20:09 ../
drwxrwxr-x  2 mayur mayur  4096 Oct 18 20:09 deploy/
-rw-rw-r--  1 mayur mayur 16008 Jul 31 12:12
-rw-rw-r--  1 mayur mayur    63 Jul 31 12:12 .gitignore
-rw-rw-r--  1 mayur mayur    93 Jul 31 12:12 .hgignore
-rw-rw-r--  1 mayur mayur     0 Jul 31 12:12
-rw-rw-r--  1 mayur mayur   548 Jul 31 12:12
-rw-rw-r--  1 mayur mayur   898 Jul 31 12:12
drwxrwxr-x  2 mayur mayur  4096 Oct 18 20:09 requirements/
-rw-rw-r--  1 mayur mayur 12759 Oct 18 20:09
-rw-rw-r--  1 mayur mayur  3856 Jul 31 12:12
-rw-rw-r--  1 mayur mayur   288 Jul 31 12:12

Make sure that .gitignore file contains This file should used only on local dev environment. On production all the settings should be handled by alone.

In , set DEBUG = True or else your static file (css, js ,images) wont be served properly


For database setup I would highly recommend that which ever database you use in production use the same on your local machine. If you use postgresql on your website I suggest you install postgresql on your local machine as well.

For simplicity reasons create a database with same name, same user and same password as that you have on your production server.

Also we will need get a sql dump of you DB from production server. We will be using it in this guide.

To backup / restore your database use django-dbbackup package .This package is really handy for DB backups n restores. Follow the "DBBackup to Local Disk" part of the documentation.

On production machine, setup django-dbbackup, take a dump of sql using this command

$ python dbbackup

and transfer it to local machine

On local machine, setup django-dbbackup, use the dump and restore it in your local database.Use this command to restore database

$ python dbrestore -f "my_production_DB_dump.sql"

Since your local DB now contains same data as your production, your database is ready to test n run locally.

Runserver Hack:

As root, edit your /etc/hosts like this

$  echo -e " \" >> /etc/hosts

As root user run the server on port like this

$ python runserver

You might think whats wrong with running server on like a normal user. Here is why

1) There is a default website in Mezzanine that runs on You do not want your traffic to be served from the default website or spend time figuring out that why aren't your changes reflecting on your website when in fact you are looking at the default website

2) Running server on as root guarantees that we will be on the safer side , away from troubles n confusion.

The only thing that will annoy you is while viewing the live website you will have to disable the entry ( ) that we just did in /etc/hosts and when you want to test again, you will have to put the entry back. For a effortless switching between live and test website do this

1) Make test website host entry like this

$ echo -e " \" >> /etc/hosts

2) Run the current website and go into admin/sites . Change the name of your website from to

3) Delete the entry from /etc/hosts

4) Done !! Now you can access your live website at and access your test website at


I hope this post gives you an idea as well as guides you as to what needs to be done to setup you local dev environment. For Heroku users, the database setup will need more tweaking that this. For rest of the people, have a less painful day.