没有Style / css在Django Admin上

时间:2022-11-13 19:17:52

I'm a complete newbie to apache, so the the whole deployment process has been a pain in the backside, so bear with me.

我是apache的新手,所以整个部署过程都是背后的痛苦,所以请耐心等待。

I'm having the problem of my admin site using the css formatting, it's just coming up as plain html.

我有使用css格式的管理站点的问题,它只是作为普通的html出现。

I know there are other questions that answer this issue here and elsewhere, but for the life of me I can't figure out to get it working. So if anyone can spot what I'm messing up I'd be eternally grateful.

我知道还有其他问题可以在这里和其他地方回答这个问题,但对于我的生活,我无法想出让它发挥作用。因此,如果有人能够发现我搞砸了什么,我将永远感激不尽。

The relevant lines in settings.py are:

settings.py中的相关行是:

STATIC_ROOT = '/var/www/logparseradmin/logparser/static'

STATIC_URL = 'http://theyard/logparseradmin/static/'

ADMIN_MEDIA_PREFIX = '/var/www/Django-1.3.1/django/contrib/admin/media/'

and I have:

我有:

Alias /static/ /var/www/Django-1.3.1/django/contrib/admin/media/

in my httpd.conf.

在我的httpd.conf中。

I've tried a whole bunch of variations on this, as the various answers on the Internet have suggested, but no luck.

我已经尝试了很多变化,因为互联网上的各种答案已经提出,但没有运气。

Thanks very much.

非常感谢。

1 个解决方案

#1


1  

There's at least three things wrong here.

这里至少有三件事是错的。

Firstly, your STATIC_URL is not probably a valid URL - http://theyard/ is not a real domain name, and won't work unless you've got local DNS resolution (which, given your self-described newbie status, seems unlikely.)

首先,你的STATIC_URL可能不是一个有效的网址 - http://他/不是真正的域名,除非你有本地DNS解析(鉴于你自己描述的新手状态,似乎不太可能) 。)

Secondly, the path value of STATIC_URL doesn't match the Alias you've put in httpd.conf - STATIC_URL has /logparseradmin/static/, whereas Alias just has /static/

其次,STATIC_URL的路径值与你在httpd.conf中放入的别名不匹配 - STATIC_URL有/ logparseradmin / static /,而Alias只有/ static /

Thirdly, ADMIN_MEDIA_PREFIX should be a URL path, not a file path.

第三,ADMIN_MEDIA_PREFIX应该是URL路径,而不是文件路径。

And without seeing the rest of your http.conf it's impossible to be sure, but there may be fourth issue with mod_wsgi matching the URL before your Alias is processed.

如果没有看到http.conf的其余部分,则无法确定,但在处理Alias之前,mod_wsgi可能存在与URL匹配的第四个问题。

#1


1  

There's at least three things wrong here.

这里至少有三件事是错的。

Firstly, your STATIC_URL is not probably a valid URL - http://theyard/ is not a real domain name, and won't work unless you've got local DNS resolution (which, given your self-described newbie status, seems unlikely.)

首先,你的STATIC_URL可能不是一个有效的网址 - http://他/不是真正的域名,除非你有本地DNS解析(鉴于你自己描述的新手状态,似乎不太可能) 。)

Secondly, the path value of STATIC_URL doesn't match the Alias you've put in httpd.conf - STATIC_URL has /logparseradmin/static/, whereas Alias just has /static/

其次,STATIC_URL的路径值与你在httpd.conf中放入的别名不匹配 - STATIC_URL有/ logparseradmin / static /,而Alias只有/ static /

Thirdly, ADMIN_MEDIA_PREFIX should be a URL path, not a file path.

第三,ADMIN_MEDIA_PREFIX应该是URL路径,而不是文件路径。

And without seeing the rest of your http.conf it's impossible to be sure, but there may be fourth issue with mod_wsgi matching the URL before your Alias is processed.

如果没有看到http.conf的其余部分,则无法确定,但在处理Alias之前,mod_wsgi可能存在与URL匹配的第四个问题。