How to Set Up Django CMS

This is step by step tutorial that explains how to install Django CMS on webfaction webhosting and set up completly your website with django cms default bootstrap template

 

Introduction

Django CMS is easy-to-use and developer-friendly CMS. It allows you frontend editing. It can be very usefull especially for clients, because standard admin panel of pure django is more complicated for no-technical moderators/users. Also I like django cms palceholders,it’s the place where a user can add text, video or any other plugin to a webpage, using either the normal Django admin interface or the so called frontend editing. This is step by step tutorial that explains how to install Django CMS on webfaction webhosting and start completely your website with django cms with default bootstrap template.  By my opinion it's the simplest way to set up django cms website .

 

What you need to set up django CMS website

First you need web hosting that wil provide you the server where you will place your data. Webfaction is easy to use django friendly web hosting with userfriendly interface. This tutorial explains every step with images for setting up Django CMS website on Webfaction .

Go to webfaction.com and sign up

Price $8.50/month (paid yearly) or $9.50/month (paid monthly)

 

Follow these steps to start Django CMS website ...

STEP 1

Log in in your webfaction dashboard panel  and add your domain . 

 

Click on DOMAINS/WEBSITES  - > Add new domain

 

Add your domain name and click on Save. You can add multiple domains. I recommend you to add domain with www and without it, for example www.example.com and example.com. In this example I will add only www.blaz1988.webfactional.com

 

STEP 2

 

After adding your domain name you should add your website , click on Websites , as shown on image below 

 

If you don't have already  created web application , click  on Create a new application . Here you'll choose your django/python  and apache version 

I recommend you to choose python2.7 with Django1.6 

 

When you load your website in web browser , you should see "It worked" message as shown below, it means that  you're created sucessfully django project on your website . 

STEP 3

 

Create mysql or posrgreSql database. Click on Databases ->Add new database

 

I've created MySql database with name  mytest_db and mysql account with username test_user.

 

STEP 4

Log in to your server with SSH , you can use http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html  . If you're linux user then you can connect  through terminal by executing command 

 

ssh username@hostname

For example ssh blaz5@blaz1988.webfactional.com

 

When you log in , and execute linux command 

 

ls

 

 

you should see something like 

 

 

in folder webapps, you'll find all projects that are created through webfaction web hosting dashboard. In my example I've created django web application called test  in STEP 2

cd webapps
ls

There are many ways to install django cms, by my opinion the simplest is to remove myproejct folder in your django project and create empty folder named as myproject and in that folder install django cms with djangocms-installer .Just follow instruction below  

cd test
rm -r myproejct
mkdir myproject
cd myproejct
ls

 

STEP 5

 

To install django CMS we'll need pip and  virtualenv . To install pip execute

easy_install-2.7 pip

To install virtualenv execute easy_install-2.7 virtualenv

easy_install-2.7 pip

If you choose in STEP 2 , other version of python than 2.7 , then you need to use diffrent version on easy install , easy_install-2.7 instal pip on Python-2.7 , so if you use Python-x.y , then use easy_install-x.y. Now we need to set up virtualenv and activate it

Set up virtual env with command 

virtualenv env

activate virtualenv with command

source env/bin/activate

 

Then you should isntall djangocms-installer

pip install djangocms-installer

 

Now we have all necessary packages to install django cms. To install it execute command 

djangocms -p parent/directory project_name

for example command

djangocms -p /home/blaz1988/webapps/myproject    myproject

will install django cms into directory "/home/blaz1988/webapps/myproject" with project name "myproject"

 

First you need to select database for django cms, by default it's sqlite, but I recommend you MySQL or PostgreSQL , because  I had some issues with sqlite .  You need to  type your database informations in URL format like : 

mysql://database_username:database_password@localhost:3306/database_name

 

Create superuser , this username and password you'll use to log in in you admin and  django CMS frontediting dashboard. 

Choose you django CMS settings as languages, templates ... 

STEP 6 

Now , if you laod your djangoCMS website you'll get error as shown below .. 

To fix this , you need to restart your apache server while your virtualen is activated. So activate your env variable , which we created in STEP 5. 

source env/bin/activate

 

Navigate to your apache folder and restart  server

cd apache2/bin
./restart

 

Viola! You created  djangoCMS website :) .. 

 

 

Note : 

Django CMS edite mode : at the end of your URL add ?edit  for example http://www.djangotutsme.com/en/?edit

Error Log : cat /home/your_username/logs/user/error_yourprojectname.log   ., for example cat /home/blaz1988/logs/user/error_test.log

Remove  language identifer  : If you're using a single language  and want to remove  language identifer  , then in your urls.py  

replace this pattern registration:

urlpatterns = i18n_patterns('',
 url(r'^admin/', include(admin.site.urls)),
 url(r'^', include('cms.urls')),
)

with this:

from django.conf.urls import patterns

urlpatterns = patterns('',
  url(r'^admin/', include(admin.site.urls)),
  url(r'^', include('cms.urls')),
)
email@djangotutsme.com Dec. 22, 2014, 5:52 a.m.