我的 Css 没有为 django rest 框架访问页面呈现,而是在使用 apache 服务器时为其他网页呈现

My Css is not being rendered for the django rest framework access page but its being rendered for other webpages when using apache server

当我使用 django 开发服务器时,css 得到正确呈现我检查了静态文件,并且文件夹中也收集了所需的 css 文件

下面是apache服务器的.conf文件 me_buildout_xmeme 是 repo 名称 memev2 是项目名称

<VirtualHost *:80 *:8080>
  ServerAdmin webmaster@example.com
  DocumentRoot /home/ubuntu/django/me_buildout_xmeme
  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined 
  Alias /static /home/ubuntu/django/me_buildout_xmeme/static 
  <Directory /home/ubuntu/django/me_buildout_xmeme/static> 
    Require all granted
  </Directory> 
  <Directory /home/ubuntu/django/me_buildout_xmeme/memev2> 
    <Files wsgi.py>  
      Require all granted
    </Files>    
  </Directory>   
  WSGIDaemonProcess memev2 python-path=/home/ubuntu/django/me_buildout_xmeme python-home=/home/ubuntu/django/myprojectenv
  WSGIProcessGroup memev2  
  WSGIScriptAlias / /home/ubuntu/django/me_buildout_xmeme/memev2/wsgi.py 
</VirtualHost>  
         

这里指的是settings.py设置

STATIC_URL = '/static/'



STATIC_ROOT = os.path.join(BASE_DIR, 'static_collected')

# STATIC_ROOT='static'

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'




STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)



 

                                                                                                                                                                                    

您的 Apache 配置服务于 static 目录,但您的 STATIC_ROOT 设置设置为 static-collected。您需要在 apache 中提供 static-collected 目录。