why my django admin site does not have the css style

后端 未结 19 1976
南笙
南笙 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:35

    Admin panel was working fine except css wasn't loaded. This worked for Lightsail Django with Apache

    1.Define STATIC_ROOT and STATIC_URL in settings.py

    STATIC_ROOT = '/opt/bitnami/projects/decisions/decision/'
    STATIC_URL = '/static/'
    

    2.Eject(copy) admin assets files to the project

    run python manage.py collectstatic this command creates /opt/bitnami/projects/decisions/decision/admin folder with css/ fonts/ img/ js/ subfolders

    3.Make /static url accessible from apache

    Paste this snippet in /opt/bitnami/apache2/conf/bitnami/bitnami.conf (If you have set up ssl then the file location will be /opt/bitnami/apache2/conf/bitnami/bitnami-ssl.conf)

    Alias /static/ "/opt/bitnami/projects/decisions/decision/"
    
        Order allow,deny
        Options Indexes
        Allow from all
        IndexOptions FancyIndexing
    
    

    4. Don't forget to restart apache

    sudo /opt/bitnami/ctlscript.sh restart apache
    

提交回复
热议问题