Django后台admin使用SimpleUi

Django后台admin使用SimpleUi


为了更美观,使用方便在Django admin的基础上引入了simpleui,一起分享如何简单利用simpleui做出更美观的Django admin后台:

  • 环境准备
  • 引入simpleui
  • 修改simple自定义模板

在这里插入图片描述

演示请点链接

演示网址

教程

目录

参考

知乎文案

cmd-markdown-logo


准备环境

安装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/;      
  • 3
    点赞
  • 33
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值