django_blog_zinnia 博客部署文档

近期有意把历来文档笔记放到博客中,GitHub上搜了几个基于python的开源博客; 
需求博客功能基本完整,最好django框架;满足前期先快速创建,后期二次开发自定义;
 
一、blog_mini(flask框架)
flask 框架 
 
试用了下,功能偏少,不过用于入门学习flask框架不错;
 
二、开源django cms
1、https://github.com/wagtail/wagtail  需求python 3.4 以上
安装文档
 
以上都是基于django的cms框架,需要学习,非开箱即用,不满足初衷;
 
三、django_blog_zinnia
测试环境部署试用了下,开箱即用,基本功能满足,同时有几款主题可选,又可以在主题基础上自己删减修改,而且后期也支持功能拓展,非常适合初中级进阶学习django框架;
 
1、安装文档
 
2、官方文档并不是很详细,补充几点需要注意的事项;
#step 1 创建虚拟环境
pip install virtualenv
virtualenv blog_zinnia_env
#step 2 安装前置依赖以及博客,可参考官方文档
#需要注意如使用mysql 作为后端数据库
pip install MySQL-python
#同时最新版本移除了python 2.x代码,所以在python2.7 环境部署需要指定版本;
pip install 'django-blog-zinnia == 0.19'
#step 3 创建django项目,编辑配置
django-admin startproject zinnia_blog_demo
#官方文档配置可能是由于django版本差异导致有细节出入,我用的django=1.11,所以在配置的时候仔细点,否则很容易配置错误;(附件会带上我的配置)
#step 4 同步数据库/部署
 python manage.py migrate
#部署  nginx + uwsgi + django  推荐这个,用gunicorn的化会遇到realIP 无法透传的问题;
#注意  需要注意时区设置/字符编码 同数据库一致,否则会遇到字符乱码/国际化问题;
#注意  静态文件收集目录权限/相关路由配置
#=====================================================================
#step 5 以上完成基本就可以完成部署,当然默认主题布局不满意,可以更该官方提供的几个主题;
#官方文档
#http://docs.django-blog-zinnia.com/en/develop/how-to/customize_look_and_feel.html
#step 6 进阶配置
#http://docs.django-blog-zinnia.com/en/develop/getting-started/configuration.html
#注意 xmlrpc功能推荐,方便导入日志
#注意 很讨厌文章预览/继续阅读这个ui设计,所以干脆改了preview.py 关了这个功能;

#step 7  附上个人的settings.py(删减了部分不需要/敏感配置)
 
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
#allow domain
ALLOWED_HOSTS = ['']
SITE_ID = 1
#support markdown
#ZINNIA_MARKUP_LANGUAGE = 'reStructuredText'
#ZINNIA_MARKUP_LANGUAGE = 'textile'
ZINNIA_MARKUP_LANGUAGE = 'markdown'
ZINNIA_MARKDOWN_EXTENSIONS = ['markdown.extensions.extra', 'markdown.extensions.codehilite']
#django_ckeditor support
CKEDITOR_IMAGE_BACKEND = True
#email setup
ZINNIA_MAIL_COMMENT_NOTIFICATION_RECIPIENTS = ['youemail@163.com',]
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.qq.com'
EMAIL_PORT = 465
EMAIL_HOST_USER = 'email@qq.com'
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_SSL = True
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER

#disable continue reading link
ZINNIA_ENTRY_CONTENT_TEMPLATES = [
  ('zinnia/_short_entry_detail.html', 'Short entry template'),
]
# Application definition
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
# new add
    'zinnia_bootstrap', #Zinnia-theme-bootstrap 
#   'zinnia_foundation',  #zinnia-theme-foundation
    'django.contrib.sites',
    'django_comments',
    'mptt',
    'tagging',
    'zinnia',
    'django.contrib.sitemaps',
    'django_xmlrpc',
    'ckeditor',
    'zinnia_ckeditor',
]
MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'zinnia_blog_demo.urls'
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': False,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
          'zinnia.context_processors.version',  # Optional
            ],
            'loaders': [
               'app_namespace.Loader',
               'django.template.loaders.filesystem.Loader',
               'django.template.loaders.app_directories.Loader',
            ],
        },
    },
]
WSGI_APPLICATION = 'zinnia_blog_demo.wsgi.application'
CKEDITOR_CONFIGS = {
    'default': {
        'toolbar': 'Full',
    },
    'zinnia-content': {
        'toolbar_Zinnia': [
            ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord'],
            ['Undo', 'Redo'],
            ['Scayt'],
            ['Link', 'Unlink', 'Anchor'],
            ['Image', 'Table', 'HorizontalRule', 'SpecialChar'],
            ['Source'],
            ['Maximize'],
            '/',
            ['Bold', 'Italic', 'Underline', 'Strike',
             'Subscript', 'Superscript', '-', 'RemoveFormat'],
            ['NumberedList', 'BulletedList', '-',
             'Outdent', 'Indent', '-', 'Blockquote'],
            ['Styles', 'Format'],
        ],
        'toolbar': 'Zinnia',
    },
}
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
#DATABASES = {
#    'default': {
#        'ENGINE': 'django.db.backends.sqlite3',
#        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
#    }
#}
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'blog',
        'USER': '',
        'PASSWORD': '',
        'HOST': '',
        'port': '3306',
    }
}

# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

#cache
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
    },
    'comparison': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
        'LOCATION': 'comparison',
        'TIMEOUT': None,
   }
}
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'zh-hans'
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_L10N = True
USE_TZ = False

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = '/var/www/'
MEDIA_ROOT = '/var/www/media'
CKEDITOR_UPLOAD_PATH = '/var/www/upload'
 

Pingbacks已打开。

Trackbacks

引用地址

评论
  1. aarp car insurance aarp car insurance 发布于 2020年10月28日 12:52 #

    <a href="http://carinsurancefive.com/">dairyland insurance</a> <a href="http://autoinsurancequoteskim.com/">car insurance cheap</a>

  2. MiaGal MiaGal 发布于 2020年10月28日 13:44 #

    <a href="https://neurontinonline.com/">prescription drug neurontin</a> <a href="https://augmentincl.com/">amoxil generic</a> <a href="https://approvedpill.com/">dipyridamole 200 mg capsules</a> <a href="https://motrinpill.com/">motrin 600mg</a> <a href="https://viagraotr.com/">viagra how to</a>

  3. JoeGal JoeGal 发布于 2020年10月28日 13:50 #

    <a href="https://bactrimmed.com/">buy bactrim online with no prescription</a> <a href="https://24antibiotics.com/">buy generic zyvox</a> <a href="https://novemeds.com/">drug betapace</a> <a href="https://azspills.com/">trental cost</a> <a href="https://augmentinpill.com/">amoxicillin 1972</a> <a href="https://suhagrasilagra.com/">suhagra for sale</a> <a href="https://metformin10.com/">how to get metformin without a prescription</a> <a href="https://viagraotr.com/">viagra online no rx</a>

  4. AnnaGal AnnaGal 发布于 2020年10月28日 14:11 #

    <a href="http://antifungalpills.com/">nizoral ketoconazole shampoo</a> <a href="http://qmedicines.com/">prazosin 5 mg cap</a> <a href="http://viagraonly.com/">generic viagra price canada</a> <a href="http://hydroxychloroquinetm.com/">hydroxychloroquine sulfate buy</a> <a href="http://levitract.com/">levitra generic usa</a>

  5. viagra without a doctor prescription viagra without a doctor prescription 发布于 2020年10月28日 17:40 #

    http://withoutdct.com - buy viagra

  6. DenGal DenGal 发布于 2020年10月28日 19:00 #

    <a href="http://cialisoon.com/">buy cialis in singapore</a> <a href="http://albuterolventolin.com/">how to order albuterol tabs without a prescription</a> <a href="http://propeciafns.com/">where can i buy propecia in india</a> <a href="http://chloroquinepack.com/">chloroquine 500 mg tablet</a> <a href="http://viagraonly.com/">price of 100mg viagra</a>

  7. Pay Day Loans Pay Day Loans 发布于 2020年10月28日 19:38 #

    <a href="http://quickloansasap.com/">best loans for bad credit</a> <a href="http://installmentloansapr.com/">loan till payday</a> <a href="http://personalloansip.com/">fair credit</a>

发表评论