Django后台admin使用SimpleUi
为了更美观,使用方便在Django admin的基础上引入了simpleui,一起分享如何简单利用simpleui做出更美观的Django admin后台:
- 环境准备
- 引入simpleui
- 修改simple自定义模板
演示请点链接
教程
参考
准备环境
安装MySQL
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
rpm -ivh mysql80-community-release-el7-3.noarch.rpm
#如果需要安装MySQL 5.7 修改 /etc/yum.repo.d/mysql-community.repo 把版本 enable gpgcheck 改为 0 1 把要安装的版本改为 1 1
yum -y install mysql-community-server
systemctl start mysqld
cat /var/log/mysql.log |grep password #查看密码
alter user root@localhost identified by '你的密码'
create database django default charset utf8; #创建数据库
安装Redis
yum -y install gcc-c++
wget https://download.redis.io/releases/redis-6.0.8.tar.gz
tar xzf redis-6.0.8.tar.gz
cd redis-6.0.8
make && make install
注释掉以下内容
路径:redis-6.0.8/utils/install_server.sh
#_pid_1_exe="$(readlink -f /proc/1/exe)"
#if [ "${_pid_1_exe##*/}" = systemd ]
#then
# echo "This systems seems to use systemd."
# echo "Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!"
# exit 1
#fi
脚本安装
sh ./install _server.sh
直接回车 默认为6379端口
直接回车 配置文件默认路径/etc/redis/6379.conf
直接回车 日志默认路径/var/log/redis_6379.log
直接回车 数据库目录文件 /var/lib/redis/6379
redis添加密码
vim /etc/redis/6379.conf
…
requirepass 123456
…
redis杀掉重新启动
redis-cli shutdown
redis-server /etc/redis/6379.conf
安装Nginx
wget https://nginx.org/download/nginx-1.20.1.tar.gz
yum install -y pcre-devel pcre zlib zlib-devel openssl openssl-devel wget gcc gcc-c++ unzip
useradd -s /sbin/nologin nginx
tar -xvf nginx-1.20.1.tar.gz
cd nginx-1.20.1/
sed -i '49s/nginx/Microsoft-IIS/' src/http/ngx_http_header_filter_module.c
sed -i '50s/: /: Microsoft-IIS/' src/http/ngx_http_header_filter_module.c
sed -i '51s/: /: Microsoft-IIS/' src/http/ngx_http_header_filter_module.c
./configure --user=nginx --group=nginx --prefix=/opt/nginx --with-http_ssl_module --with-http_stub_status_module --with-stream --with-http_realip_module --with-http_realip_module
make && make install
cp -r /opt/nginx/sbin/nginx /usr/sbin/nginx
mkdir /opt/nginx/conf.d
mv /opt/nginx/conf/nginx.conf /opt/nginx/conf/nginx.bak.conf
修改 nginx 配置文件
vim /opt/nginx/conf/nginx.conf
worker_processes auto;
error_log logs/error.log error;
pid logs/nginx.pid;
events {
worker_connections 65535;
multi_accept on;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
keepalive_timeout 60;
add_header Access-Control-Allow-Origin '*';
add_header Access-Control-Max-Age '3628800';
add_header Access-Control-Allow-Credentials 'true';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
add_header Access-Control-Allow-Methods 'GET,POST,PUT,OPTIONS';
underscores_in_headers on;
client_header_buffer_size 32k;
client_body_buffer_size 20m;
client_max_body_size 120M;
client_header_timeout 1m;
client_body_timeout 1m;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
large_client_header_buffers 4 32k;
fastcgi_buffers 4 128k;
fastcgi_buffer_size 128k;
fastcgi_busy_buffers_size 256k;
server_tokens off;
tcp_nopush on;
tcp_nodelay on;
sendfile on;
gzip on; #开启gzip
#gzip_static on;
gzip_vary on;
gzip_min_length 1k;
gzip_buffers 8 32k;
gzip_http_version 1.1;
gzip_comp_level 6;
gzip_proxied any;
gzip_types application/javascript application/json text/css image/png;
real_ip_header X-Real-IP;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
include /opt/nginx/conf.d/*.conf;
}
创建一个django.conf(/opt/nginx/conf.d/django.conf)
server {
listen 80;
server_name localhost;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:3210;
uwsgi_read_timeout 180s;
uwsgi_connect_timeout 180s; #
uwsgi_send_timeout 180s; #默认60s;
index index.html index.htm;
}
location /static {
expires 30d;
autoindex on;
add_header Cache-Control private;
alias /opt/app/static/; #写项目的的静态路径,如果不开启debug 执行python3 manage.py collectstatic 有自动创建项目下static路径