Asked 1 years ago
20 Jul 2023
Views 365
Cimb

Cimb posted

Django Admin is loading without css

Django Admin is loading without css
as well frontend css also not loading from static folder

STATIC_URL , STATIC_ROOT , STATICFILES_DIRS ,MEDIA_URL ,MEDIA_ROOT is as below in setting.py
setting.py

STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

#this code
STATICFILES_DIRS = [
    BASE_DIR / "static",
]
MEDIA_URL = "/media/"
MEDIA_ROOT = BASE_DIR / "media/"


so as i am using apache so i checked configuration of apache as well
which is at
/etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>
	ServerAdmin webmaster@localhost
	DocumentRoot /home/ubuntu/projectfolder
	ServerName 52.4.98.17
	Alias /static /home/ubuntu/projectfolder//static
    <Directory /home/ubuntu/projectfolder/>
        Require all granted
    </Directory> 
  
 WSGIDaemonProcess projectname python-home=/home/ubuntu/projectfolder/my_env python-path=/home/ubuntu/projectfolder
 WSGIProcessGroup projectname
  WSGIScriptAlias / /home/ubuntu/projectfolder/appname/wsgi.py
  
  <Directory /home/ubuntu/projectfolder/appname>
    <Files wsgi.py>
      Require all granted
    </Files>
  </Directory>
</VirtualHost>




not sure where it goes wrong
steave

steave
answered Jul 20 '23 00:00

change file part of /etc/apache2/sites-available/000-default.conf

Alias /static /home/ubuntu/projectfolder/static
    <Directory /home/ubuntu/projectfolder/static>
        Require all granted
    </Directory> 


try above change it should work
Post Answer