gpt4 book ai didi

python django media_root

转载 作者:太空宇宙 更新时间:2023-11-03 19:31:51 24 4
gpt4 key购买 nike

如果我使用下面的代码,它将在项目文件夹下找到我的base.css:

<link rel="stylesheet" type="text/css" href="{% block stylesheet %}/media/a/admin/css/base.css{% endblock %}" />

MEDIA_ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'media')
MEDIA_URL = '/media/a/'
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),

但是,如果我使用下面的代码,它将转到 \Python25\Lib\site-packages\django\contrib\admin\media\css 查找 base.css:

<link rel="stylesheet" type="text/css" href="{% block stylesheet %}/a/admin/css/base.css{% endblock %}" />

MEDIA_ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'media')
MEDIA_URL = '/a/'
(r'^a/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),

有谁知道为什么会出现这种情况吗?

谢谢~~

最佳答案

我猜您有 ADMIN_MEDIA_PREFIX = '/a/admin/'

http://docs.djangoproject.com/en/dev/ref/settings/#admin-media-prefix

Make sure to use a trailing slash, and to have this be different from the MEDIA_URL setting (since the same URL cannot be mapped onto two different sets of files).

关于python django media_root,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5410086/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com