http://www.th7.cn/Program/Android/201306/141207.shtml
1. 安装django-blog-zinna及其相关依赖包
包依赖
- 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.
- pytz
- South >= 0.7.6
- pyparsing >= 1.5.5 < 2.0.0
- django-xmlrpc >= 0.1.5
cms related
- cmsplugin-zinnia >= 0.4
- django-cms >=2.3 & <2.4
- django-menus >= 1.1
- django-sekizai >= 0.7
2. settings.py新增配置:
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',
)
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',# migration models into mysql for apps
'south',# extend permisson
'guardian',
'blog',# fml apps
'piqiu',
'books',
'polls',
'southtut',
'Jiaion',
'comments',
'hello',
'tagging',
'mptt',
'zinnia',
'cms',
'menus',
'cmsplugin_zinnia',
'sekizai',
)
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 %}
{% render_block "css" %}
{% cms_toolbar %}
{% placeholder base_content %}
{% block base_content %}{% endblock %}
{% render_block "js" %}
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.*)$', '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 标准视图: