基于django+sqlite3的新闻网站管理系统源代码,含数据库文件
程序部署方法
1、安装程序依赖;
2、 manage.py migrate #初始化数据库;
3、 manage.py createsuperuser创建管理员;
4、manage.py runserver启动程序
完整程序下载地址:基于django+sqlite3的新闻网站管理系统源代码
首页
后台管理
发布新闻
核心代码
"""
Django settings for news project.Generated by 'django-admin startproject' using Django 4.0.3.For more information on this file, see
https://docs.djangoproject.com/en/4.0/topics/settings/For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
"""
import osfrom pathlib import Path# 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/4.0/howto/deployment/checklist/# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-vvf5fcm%gok*#-)cr0u3ckrofiwn_g$(s!z0=98=-9i)tgppdw'# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = TrueALLOWED_HOSTS = ['*']# Application definitionINSTALLED_APPS = ['simpleui',# 'import_export','mdeditor','django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','login','user',]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','login.SimpleMiddleware.SimpleMiddleware'
]ROOT_URLCONF = 'news.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',# 上下文处理器# 'blog.context_processors.sidebar',# 'blog.context_processors.website_conf',# templates中使用 {{ MEDIA_URL }}{{ 文件名 }} 拼接文件地址'django.template.context_processors.media',],# 用于在模板中自动调用静态文件,不需要每个页面使用 {% load static %} 加载静态文件'builtins': ['django.templatetags.static',],},},
]WSGI_APPLICATION = 'news.wsgi.application'# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databasesDATABASES = {'default': {'ENGINE': 'django.db.backends.sqlite3','NAME': BASE_DIR / 'db.sqlite3',}
}# Password validation
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validatorsAUTH_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/4.0/topics/i18n/LANGUAGE_CODE = 'zh-Hans'TIME_ZONE = 'Asia/Shanghai'USE_I18N = TrueUSE_TZ = False
X_FRAME_OPTIONS = 'SAMEORIGIN'
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads')
MEDIA_URL = '/media/'STATIC_URL = '/static/'
STATICFILES_DIRS = [BASE_DIR / "static"]SIMPLEUI_LOGO = '/static/img/logo.png'# simpleui 排序后台app导航栏
SIMPLEUI_CONFIG = {'system_keep': True,'menu_display': ['新闻管理', '用户管理', '网站配置', '管理员'],'dynamic': True,'menus': [{'name': '新闻管理','models': [{'name': '新闻列表','url': '/admin/login/news/'}, {'name': '分类列表','url': '/admin/login/type/'}, {'name': '留言列表','url': '/admin/login/message/'}]}, {'name': '网站配置','models': [{'name': '友情链接列表','url': '/admin/login/href/'}, {'name': '赞赏列表','url': '/admin/login/admiration/'}, {'name': '相关信息','url': '/admin/login/myhref1/'}]}, {'name': '用户管理','icon': 'fas fa-user-shield','models': [{'name': '用户列表','url': '/admin/login/user/'}, {'name': '管理员列表','icon': 'fa fa-user','url': 'auth/user/'}]}]
}
# 隐藏右侧SimpleUI广告链接和使用分析
SIMPLEUI_HOME_INFO = False
SIMPLEUI_ANALYSIS = False
# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-fieldDEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
完整程序下载地址:基于django+sqlite3的新闻网站管理系统源代码