Python个人网盘源码、云盘系统源程序,基于Django+Mysql
Python个人网盘源码、云盘系统源程序,基于Django+Mysql。2、检查配置文件,修改邮箱和数据库配置。4、执行基础sql文件。
·
Python个人网盘源码、云盘系统源程序,基于Django+Mysql
1、安装依赖
pip install -r requirements.txt
2、检查配置文件,修改邮箱和数据库配置
# mycloud/settings.py
EMAIL_HOST = 'smtp.qq.com'
EMAIL_PORT = '587'
EMAIL_HOST_USER = '******'
EMAIL_HOST_PASSWORD = '******'
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'cloud',
'HOST': '127.0.0.1',
'PORT': '3306',
'USER': '***',
'PASSWORD': '******',
}
}
3、迁移数据库
python manage.py migrate
4、执行基础sql文件
mysql> use cloud;
mysql> source C:/Users/..../.sql;
5、创建超级用户
python manage.py createsuperuser
6、启动本地服务器
python manage.py runserver
完整程序代码下载地址:Python个人网盘源码、云盘系统源程序,基于Django+Mysql
程序运行截图
settting.py
"""
Django settings for mycloud project.
Generated by 'django-admin startproject' using Django 3.2.8.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
from pathlib import Path
from secrets import token_hex
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-wx8cyt+)#o!8f&7rrz!$5-s$*e_kciv44gycm!l0y9p83js83j'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
EMAIL_HOST = 'smtp.qq.com'
EMAIL_PORT = '587'
EMAIL_HOST_USER = '******'
EMAIL_HOST_PASSWORD = '******'
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
# Application definition
INSTALLED_APPS = [
'simpleui',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'pan.apps.PanConfig',
'corsheaders',
'rest_framework',
# 'debug_toolbar',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
# 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
]
ROOT_URLCONF = 'mycloud.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates'],
'APP_DIRS': True,
'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',
],
},
},
]
WSGI_APPLICATION = 'mycloud.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'cloud',
'HOST': '127.0.0.1',
'PORT': '3306',
'USER': '***',
'PASSWORD': '******',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.2/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',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/
LANGUAGE_CODE = 'zh-hans'
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR / 'static'
MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'media'
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
LOGIN_URL = '/'
# Upload avatar limit
MAX_AVATAR_SIZE = 3145728
# Cross origin
CORS_ALLOWED_ORIGINS = [
'http://localhost:8000',
'http://127.0.0.1:8000',
]
# Rest framework
REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
'PAGE_SIZE': 8
}
# Debug toolbar
# INTERNAL_IPS = [
# '127.0.0.1'
# ]
# reset token
RESET_TOKEN = token_hex(8)
RESET_PASSWORD = '123456'
TOKEN_EXPIRY = 1800
完整程序代码下载地址:Python个人网盘源码、云盘系统源程序,基于Django+Mysql
更多推荐
已为社区贡献8条内容
所有评论(0)