why my django admin site does not have the css style

后端 未结 19 1980
南笙
南笙 2020-12-02 07:49

I make a Django admin site using Django development version

But it does not have a CSS style :

\"alt

19条回答
  •  天涯浪人
    2020-12-02 08:30

    In the issue is in a dev/test/prod server and using Nginx, please follow the below steps.

    • set the configs in settings.py as something below

      STATIC_URL = '/static/'
      
      BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
      STATIC_ROOT = os.path.join(BASE_DIR, 'static')
      
    • Run the below command to create css and js files in static folder

      $ python manage.py collectstatic
      
    • config in /etc/nginx/sites-enabled/example (Nginx) to serve static files

      location /static/ {
              alias /project/root/folder/static/;
      }
      

提交回复
热议问题