Django管理CSS文件不具有可访问性,不建议使用ADMIN_MEDIA_PREFIX

时间:2022-11-13 19:18:10

I'm a first time django user. I had to manually add in the following deprecated function to the new django1.4 settings.py file for my admin css to be accessible. How can make my site look pretty without using this deprecated function?

我是django的第一个用户。我必须手动向新的django1.4设置添加以下已废弃的函数。为我的管理css是可访问的py文件。如果不使用这个废弃的函数,如何使我的站点看起来更漂亮呢?

ADMIN_MEDIA_PREFIX = '/static/admin/'

Here are my other settings for your perusal:

以下是我的其他设置供您参考:

STATIC_ROOT = '/home/ubuntu/static/' 
STATIC_URL = '/static/'

And my apache http.conf file has:

和我的apache http。配置文件有:

Alias /static/ /home/ubuntu/static/
<Directory /home/ubuntu/static>
Order deny,allow
Allow from all
</Directory>

1 个解决方案

#1


2  

You must run

你必须运行

./manage.py collectstatic

to copy all static files from packages to static directory. Of course django.contrib.staticfiles must be in INSTALLED_APPS.

将所有静态文件从包复制到静态目录。当然django.contrib。静态文件必须在INSTALLED_APPS中。

There will be folder "admin" in static folder after that. If it exists and still static files not loaded, then look to your webserver config.

之后的静态文件夹中会有“admin”文件夹。如果它存在并且仍然没有加载静态文件,那么请查看您的webserver配置。

#1


2  

You must run

你必须运行

./manage.py collectstatic

to copy all static files from packages to static directory. Of course django.contrib.staticfiles must be in INSTALLED_APPS.

将所有静态文件从包复制到静态目录。当然django.contrib。静态文件必须在INSTALLED_APPS中。

There will be folder "admin" in static folder after that. If it exists and still static files not loaded, then look to your webserver config.

之后的静态文件夹中会有“admin”文件夹。如果它存在并且仍然没有加载静态文件,那么请查看您的webserver配置。