1. 安裝django-blog-zinna及其相關依賴包css
包依賴html
- Python >= 2.6.5
- Django >= 1.5
- PIL >= 1.1.6 or Pillow >= 2.0.0
- django-mptt >= 0.5.1 < 0.6
- django-tagging >= 0.3.1
- beautifulsoup4 >= 4.1.3
The packages below are optionnal but needed for run the full test suite or migrate the database.python
- pytz
- South >= 0.7.6
- pyparsing >= 1.5.5 < 2.0.0
- django-xmlrpc >= 0.1.5
cms relatedmysql
- cmsplugin-zinnia >= 0.4
- django-cms >=2.3 & <2.4
- django-menus >= 1.1
- django-sekizai >= 0.7
2. settings.py新增配置:git
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',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'cms.middleware.multilingual.MultilingualURLMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
)github
INSTALLED_APPS = (
# django built-in
'django.contrib.auth',
'django.contrib.admin',
'django.contrib.sites',
'django.contrib.comments',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.admindocs',
'django.contrib.contenttypes',
'django.contrib.messages',
'django.contrib.staticfiles',web# migration models into mysql for apps
'south',sql# extend permisson
'guardian',
'blog',django# fml apps
'piqiu',
'books',
'polls',
'southtut',
'Jiaion',
'comments',
'hello',
'tagging',
'mptt',
'zinnia',
'cms',
'menus',
'cmsplugin_zinnia',
'sekizai',
)session
TEMPLATE_CONTEXT_PROCESSORS = (
'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',
'zinnia.context_processors.version',
'cms.context_processors.media',
'sekizai.context_processors.sekizai',
)
CMS_TEMPLATES = (
('template_1.html', 'Template One'),
('template_2.html', 'Template Two'),
)
3. 同步數據模型
. ~/.fml
cd ~/envs/fml
source bin/active
cd ~/PycharmProjects/fml
./manage.py syncdb --all
4. 新增模板文件
base.html
{% load cms_tags sekizai_tags %}
<html>
<head>
{% render_block "css" %}
</head>
<body>
{% cms_toolbar %}
{% 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_2.html
{% extends "base.html" %}
{% load cms_tags %}{% block base_content %}
{% placeholder template_2_content %}
{% endblock %}
5. urls.py配置
# admin
urlpatterns += patterns('',
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^weblog/', include('zinnia.urls.quick_entry')),
url(r'^weblog/', include('zinnia.urls.entries')),
url(r'^weblog/', include('zinnia.urls')),
url(r'^comments/', include('django.contrib.comments.urls')),
url(r'^', include('cms.urls')),
)if settings.DEBUG:
urlpatterns = patterns('',
url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
url(r'', include('django.contrib.staticfiles.urls')),
) + urlpatterns
6. 啓動django
./manage.py runserver
7. weblog 標準視圖: