Name Last Update
forum Loading commit data...
xp Loading commit data...
.gitignore Loading commit data...
LICENSE Loading commit data...
README.md Loading commit data...
forum.sql Loading commit data...
manage.py Loading commit data...
requirements.txt Loading commit data...

README.md

Django forum

安装部署

主机版:

依赖MySQL数据库,以及memcached

  1. 获取代码
  2. 安装依赖
  3. 导入数据库文件
  4. 修改配置文件
  5. 运行服务
shell> git clone git@github.com:zhu327/forum.git

shell> cd forum
shell> pip install -r requirements.txt

shell> mysql -u YOURUSERNAME -p

mysql> create database forum;
mysql> exit

shell> mysql -u YOURUSERNAME -p --database=forum < forum.sql

修改xp/settings.py

# 修改数据库配置
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'forum',                      # Or path to database file if using sqlite3.
        # The following settings are not used with sqlite3:
        'USER': 'root',
        'PASSWORD': '',
        'HOST': '127.0.0.1',                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
        'PORT': '3306',                      # Set to empty string for default.
    }
}

# 修改memcached配置,如果没有memcahed请删除这些与cache相关的内容
CACHES = { # memcached缓存设置
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': '127.0.0.1:11211',
    }
}

SESSION_ENGINE = 'django.contrib.sessions.backends.cache' # 使用memcached存储session

# 配置邮件发送
EMAIL_HOST = 'smtp.qq.com'
EMAIL_PORT = 25
EMAIL_HOST_USER= '*********'
EMAIL_HOST_PASSWORD= '******'
DEFAULT_FROM_EMAIL = '*********@qq.com'

运行服务

python manage.py runserver

默认超级用户admin@admin.com,密码123456,后台/manage/admin/

生产环境下推荐使用gunicorn.