Django管理员不提供Apache上的静态文件 [英] Django admin not serving static files on Apache

查看:112
本文介绍了Django管理员不提供Apache上的静态文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到类似的问题,但他们已经超过4年了,答案不再工作了。我有一个在Apache上正常运行的站点,除了admin staticfiles。静态文件可以与Django的runserver一起工作。我有点迷失在这里,任何建议都会有帮助。

解决方案

当您使用apache提供静态文件时,在/ var / www / html目录中。我经历了与你同样的情况。收藏没有为我工作。我所做的是,将admin应用程序的静态内容复制到/ var / www / html / static / admin 。此管理目录包含四个其他目录 css,fonts,img和js 。在我的情况下apache安装是默认的,所以/ var / www / html是我的公共目录。以下内容可供参考。

 服务器
|
-var
|
-www
|
-html
|
- static
|
-admin
| -css
| -fonts
| -img
| -js

您可以尝试上述方法。如果您让知道问题得到解决将是有帮助的。


I've seen similar questions but they are more than 4 years old and the answers doesn't work anymore. I have a site that works correctly on Apache, except for the admin staticfiles. The staticfiles work fine with Django's runserver. I'm kind of lost here, any advice will help.

解决方案

When you serve static files using apache, static folder is supposed to be in your /var/www/html directory. I had gone through same scenario as yours. collectstatic didnt work for me. What I did was, copied static contents of admin app to /var/www/html/static/admin. This admin directory contains four other directories css, fonts, img and js. In my case apache setup was the default so /var/www/html was my public directory. Following can be used for reference.

server
    |
    -var
       | 
        -www
            |
             -html
                  |
                  - static
                         |
                         -admin
                               |-css
                               |-fonts
                               |-img
                               |-js

You can try aforementioned approach. It would be helpful if you let know issue is resolved.

这篇关于Django管理员不提供Apache上的静态文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆