reference: http://docs.django-cms.org/en/2.2/getting_started/tutorial.html
User virtualenv and pip to avoid dependency problems.
$ yum install python2.6 python-setuptools python-imaging $ virtualenv mysite-env $ source mysite-env/bin/activate (env)$ pip install django==1.3.1 django-cms south (env)$ django-admin.py startproject mycmsproject
Starting project may issue error PIL (python image lib) not installed. Installing PIL requires python-devel to compile PIL:
$ sudo yum install python-devel (env)$ pip search PIL (env)$ pip install PIL (env)$ pip install django-filer cmsplugin-filer (env)$ pip install django-reversion
Installed apps
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'django.contrib.staticfiles',
'cms',
'menus',
'mptt',
'south',
'filer',
'cmsplugin_filer_file',
'cmsplugin_filer_folder',
'cmsplugin_filer_image',
'cmsplugin_filer_teaser',
'cmsplugin_filer_video',
'cms.plugins.text',
## disabled due to filer
#'cms.plugins.picture',
#'cms.plugins.file',
##
'cms.plugins.link',
'cms.plugins.snippet',
'cms.plugins.googlemap',
'sekizai',
# cmsplugin-blog
'cmsplugin_blog',
'simple_translation',
#'staticfiles',
'tagging',
'missing',
'guardian', # optional
)
Middleware classes
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'cms.middleware.multilingual.MultilingualURLMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cmsplugin_blog.middleware.MultilingualBlogEntriesMiddleware',
)
TEMPLATECONTEXTPROCESSORS:
TEMPLATECONTEXTPROCESSORS = (
'django.contrib.auth.context_processors.auth', 'django.core.context_processors.i18n', 'django.core.context_processors.request', 'django.core.context_processors.media', 'django.core.context_processors.static', 'cms.context_processors.media', 'sekizai.context_processors.sekizai',
)
1 from django.conf.urls.defaults import *
2 from django.contrib import admin
3 from django.conf import settings
4
5 admin.autodiscover()
6
7 urlpatterns = patterns('',
8 url(r'^admin/', include(admin.site.urls)),
9 url(r'^', include('cms.urls')),
10 )
11
12 if settings.DEBUG:
13 urlpatterns = patterns('',
14 url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
15 {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
16 url(r'', include('django.contrib.staticfiles.urls')),
17 ) + urlpatterns
18
CMS_TEMPLATES = (
('template_1.html', 'Template One'),
('template_2.html', 'Template Two'),
)
Inside folder pjs_root/templates
base.html
{% load cms_tags sekizai_tags %}
<html>
<head>
{% render_block "css" %}
</head>
<body>
{% placeholder base_content %}
{% block base_content%}{% endblock %}
{% render_block "js" %}
</body>
</html>
template_1.html
{% extends "base.html" %}
{% load cms_tags %}
{% block base_content %}
{% placeholder template_1_content %}
{% endblock %}
Template for cmsplugin-blog must contain a 'content' block
{% placeholder content %}
as seen in cmspluginblog/templates/cmspluginblog/entry_detail.html
13 {% with object.placeholders|choose_placeholder:"content" as content %}
14 {% render_placeholder content %}
15 {% endwith %}
At the moment static files in dev mode do not work quite 'out of the box'. Sometime when a site is openned, the runserver console says it can not find a certain js or css files. The best way for now is to collect all static files and add their folder to static file settings.
Use staticfiles modul to copy all static files in STATIC_ROOT dir, in this case the 'static' folder. This is normally done when the site is deployed.
./manage.py collectstatic
then
mv static static_dev
Now add the static_dev to settings
76 77 STATICFILES_DIRS = ( 78 os.path.join(PROJECT_DIR, 'static_dev'), 79 ) 80
User can use an app to download themes from the website and upload/apply them using 'admin' interface. It does not work properly at the moment
http://www.djangocmsthemes.com/getting-started
install the django-cms-themes pluggable django app. The best way to do this is to use the command “pip install django-cms-themes” (if you are using pip).
Add 'cmsthemes' to INSTALLEDAPPS in your settings file.
Make sure you have a setting in your settings.py file called PROJECTDIR, which should point to the root of your project in the filesystem, i.e. PROJECTDIR = os.path.abspath(os.path.dirname(file))
Run “python manage.py syncdb” (or “python manage.py migrate” if you have south installed).
Themes for the website are installed to 'themes' folder inside your webroot. CSS links and images are configured with this default path.
[td@localhost vfoss_cms]$ tree themes
themes
├── simple
│ ├── static
│ │ ├── css
│ │ │ └── style.css
│ │ └── images
│ │ ├── bullet.png
│ │ ├── graphic.png
│ │ ├── paperclip.png
│ │ └── pattern.png
│ └── templates
│ └── index.html
└── summer
├── static
│ ├── css
│ │ └── styles.css
│ ├── images
│ │ ├── 1.jpg
│ │ ├── 2.jpg
│ │ ├── 3.jpg
│ │ ├── 4.jpg
│ │ ├── body-bg.jpg
│ │ ├── tabs_1.gif
│ │ └── tabs_2.gif
│ └── js
│ ├── jquery-1.3.2.min.js
│ ├── jquery.cycle.all.min.js
│ ├── script.js
│ └── superfish.js
└── templates
├── content.html
└── index.html
-------- settings.py ------------
...
100 CMS_TEMPLATES = (
101 ('example.html', 'Example Template'),
102 ('template_1.html', 'Template 1'),
103 ('template_2.html', 'Template 2'),
104 ('summer/templates/index.html', 'summer'), <===== make index.html a template.
105 )
106
107 ROOT_URLCONF = 'urls'
108
109 TEMPLATE_DIRS = (
110 os.path.join(PROJECT_DIR, 'templates'),
111 os.path.join(PROJECT_DIR, 'themes'), <==== add template dir.
112 )
113
...
Problem:
Cause: django dev-enviroment doesn't serve static file. Before deployment python manage.py collectstatic must be run so that all static files are copied to “settings.STATIC_ROOT” by python-staticfiles. See python-staticfiles documentation.
Solution: move all static files to 'static-dev' and add 'os.path.join(PROJECTPATH, “static-dev/jquery/”),' to 'settings.STATICFILESDIRS'.