install django-cms
I am working on Ubuntu 9.10 here, not windows or mac…sorry, although I dont expect things will be much different for mac at least…if I get a chance i’ll run through this process on windows too and update the article but no promises.
I’m assuming that Python, Django and sqlite3 are installed already. For reference, I am currently using Python 2.6.4 and Django (trunk version) 1.2.
I have lifted a good chunk of this from the official django-cms installation guide, the rest came from googling and trial and error. I found the official guide a little above my head so thought i’d keep notes on what I had to do to get this running.
Aaaannnnyway…
If you dont already have one, create a new folder for your code to live in. My folder lives in my home directory and is named “django_apps”. This will pop up throughout this guide so if you’re following along and you call yours something else, remember to replace “django_apps” with the name of your own folder when the time comes.
In a terminal, move into your code directory:
CD ~/django_apps
Create a new Django project (call this whatever you like but remember to change it if you’re following along and have called it something else):
django-admin.py startproject project-name
No harm in making sure that all is indeed well at this early stage so:
CD project-name
And…
python manage.py runserver
Head on over to 127.0.0.1:8000 and if you see “it worked” then well, its working!
Here comes the science…
If you dont happen to know your Python location then issue the following commands:
python
which python
(my one was “/usr/local/lib/python2.6” for example)
Go to your Python dist-packages directory “your-python-path/dist-packages”
Download the latest and greatest Django CMS from here: http://www.django-cms.org/en/downloads/ (at the time of writing, this is version 2.0.2)
Unzip the downloaded file into the “dist-packages” directory…you will need to do this as “sudo” unless you have your system set up wrongly ;)
Make copies of the following directories like so:
sudo cp -R digi604-django-cms-2.0-c0288a1/cms/ cms
sudo cp -R digi604-django-cms-2.0-c0288a1/mptt/ mptt
sudo cp -R digi604-django-cms-2.0-c0288a1/publisher/ publisher
Do a bit of house cleaning to get rid of all the files you don’t need:
sudo rm -rf digi604-django-cms-2.0-c0288a1.zip
sudo rm -rf digi604-django-cms-2.0-c0288a1/
Head back to the project you created previously
cd ~/django_apps/project-name
In your editor, edit “settings.py” like so:
On lines 1+2 put the following before anything else:
import os
PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
Then, after the import statements , add this:
gettext = lambda s: s
Set up the remainder of the file with the following changes/additions:
DATABASE_ENGINE = ‘sqlite3’
DATABASE_NAME = ‘/path/to/your/data/your-db-name.db/
MEDIA_ROOT = os.path.join(PROJECT_PATH, ‘media’)
MEDIA_URL = ‘/media/’
ADMIN_MEDIA_PREFIX = ‘/media/admin/’
INSTALLED_APPS = (
’django.contrib.auth’,
’django.contrib.admin’,
’django.contrib.contenttypes’,
’django.contrib.sessions’,
’django.contrib.sites’,
’django.contrib.messages’,
’cms’,
’cms.plugins.text’,
’cms.plugins.picture’,
’cms.plugins.link’,
’cms.plugins.file’,
’cms.plugins.snippet’,
’cms.plugins.googlemap’,
’mptt’,
’publisher’,
)
MIDDLEWARE_CLASSES = (
’django.middleware.common.CommonMiddleware’,
’django.contrib.sessions.middleware.SessionMiddleware’,
’django.middleware.csrf.CsrfViewMiddleware’,
’django.middleware.csrf.CsrfResponseMiddleware’,
’django.contrib.auth.middleware.AuthenticationMiddleware’,
’django.contrib.messages.middleware.MessageMiddleware’,
’django.middleware.locale.LocaleMiddleware’,
’cms.middleware.page.CurrentPageMiddleware’,
’cms.middleware.user.CurrentUserMiddleware’,
)
TEMPLATE_CONTEXT_PROCESSORS = (
’django.core.context_processors.auth’,
’django.core.context_processors.i18n’,
’django.core.context_processors.request’,
’django.core.context_processors.media’,
’cms.context_processors.media’,
)
(I didnt have a “TEMPLATE_CONTEXT_PROCESSORS” specified so had to add all of the above anew.)
Set up your available templates (dont worry that they dont actually exist right now, its not that important. Perhaps i’ll write about templates next as I discover more.)
CMS_TEMPLATES = (
(‘base.html’, gettext(‘default’)),
(‘2col.html’, gettext(‘2 Column’)),
(‘3col.html’, gettext(‘3 Column’)),
(‘extra.html’, gettext(‘Some extra fancy template’)),
)
Next, Edit your “urls.py” file like so:
urlpatterns = patterns(”,
(r’^media/(?P<path>.*)$’, ‘django.views.static.serve’, {‘document_root’: settings.MEDIA_ROOT } ),
(r’^admin/’, include(admin.site.urls)),
(r’^’, include(‘cms.urls’)),
)
Create a folder called ‘media’ in your project root (that’s “project-name” for me), this means you create a symbolic link from the “cms/media/cms” folder in “dist-packages” to your new “media” folder:
ln -s /usr/local/lib/python2.6/dist-packages/cms/media/cms cms
Now for the magic…if you’re not already there:
cd ~/django_apps/project-name
python manage.py syncdb
If all goes well, you’ll be asked if you want to set up your superuser account…which of course you do so just follow the instructions in the terminal.
That should hopefully be that. If your development server is still running in your terminal stop it, then restart it again just to be sure.
cmd c
python manage.py runserver
Visit http://127.0.0.1:8000/ to make sure all is well, you’ll be greeted with appropriate text and if you can see the django-cms logo then your media folder is cool also.
log in via the admin link and enjoy :)
Posted via web from Mark McAulay | Comment »