zoukankan      html  css  js  c++  java
  • django关于静态的信息的配置

    今天搭建完,django后,访问 admin 发现  样式没有加载

    需要搭建静态的配置

    1 设置项目目录的静态目录 用来存放静态的文件

    在setttings.py中 添加以下参数  在

    STATIC_URL = '/static/'的后面
    STATIC_ROOT = os.path.join(BASE_DIR, 'static')

    2 运行django命令,收集相关的

    python manage.py collectstatic

    3 在域名相关的配置文件中 增加对static访问的目录,贴个完整的供参考

    server
    {
        listen         80;
        server_name    nginx.***.net;
    
        location ~ ^/NginxStatus/ {
        stub_status on;
        access_log off;
        }
    
    
    
        location / {
    
             index   index.html index.htm;
                #下面是设置uwsgi的方式访问python
                include  uwsgi_params;
                uwsgi_pass  127.0.0.1:8000;
                uwsgi_param UWSGI_SCRIPT mysite.wsgi;
                uwsgi_param UWSGI_CHDIR /var/www/python/newblog/;
                client_max_body_size 35m;
    
        }
    
         #下面是访问静态的内容
            location /static {
            expires 30d;
            autoindex on;
            add_header Cache-Control private;
            alias /var/www/python/newblog/static/;#主要是这段内容
         }
    }

     4 刷新下页面看看,效果出来了

  • 相关阅读:
    腾讯云启动jenkins
    腾讯云centos7.5安装jdk1.8
    windows安装python2.7、python3.7和pycharm
    centos
    jquery----Ajax异步获取数据添加到表格中
    java----封装思想
    js----对table操作
    jquery----Ajax补充
    jquery----ajax解决scrf问题
    jquery----Ajax
  • 原文地址:https://www.cnblogs.com/baker95935/p/9149800.html
Copyright © 2011-2022 走看看