自定义 django 的管理:如何将样式表放置在您想要的位置?
我尝试自定义 django 的管理 css...但我被困住了...我确实在这里找到了很多类似的讨论...仍然不清楚...这是我所看到的
... base.html,我们
<link rel="stylesheet" type="text/css" href="{% block stylesheet %}{% load adminmedia %}{% admin_media_prefix %}css/base.css{% endblock %}"
在已安装的管理中解析了该行
<link rel="stylesheet" type="text/css" href="/media/css/base.css">
,base.html 最初位于
C:\Python27\Lib\site-packages\django\contrib\admin\templates\admin
中以自定义管理应用程序,我复制了管理\模板\管理 到我的项目模板目录。然后我将所有 C:\Python27\Lib\site-packages\django\contrib\admin\media 复制到我的项目中作为 PROJECT_ROOT\media。
我希望
<link rel="stylesheet" type="text/css" href="/media/css/base.css">
将 PROJECT_ROOT\media\ 用于 css...
但是,django 仍然使用 C:\Python27\Lib\site-packages\django\contrib\admin\media ....
有人可以解释一下为什么吗?
此外,我需要做什么才能让 href="/media/css/base.css" 使用 PROJECT_ROOT\media\?
谢谢。
I tried to customize django's admin css....but I'm stuck ....i did find a lot of similar discussions here...still I'm not clear... here is what I see...
In base.html, we have
<link rel="stylesheet" type="text/css" href="{% block stylesheet %}{% load adminmedia %}{% admin_media_prefix %}css/base.css{% endblock %}"
the line resolves to
<link rel="stylesheet" type="text/css" href="/media/css/base.css">
in the installed admin, base.html is originally located in
C:\Python27\Lib\site-packages\django\contrib\admin\templates\admin
to customize the admin app, I copied admin\templates\admin
to my project templates directory. And then I copied all the C:\Python27\Lib\site-packages\django\contrib\admin\media to my project as PROJECT_ROOT\media.
I hope
<link rel="stylesheet" type="text/css" href="/media/css/base.css">
will use PROJECT_ROOT\media\ for css.....
However, django still uses C:\Python27\Lib\site-packages\django\contrib\admin\media ....
could some one explain why?
Further, what I need to do to let href="/media/css/base.css" use PROJECT_ROOT\media\?
thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保在 ADMIN_MEDIA_PREFIX:
另外,如果您使用 django 的开发服务器,请参阅 如何提供静态文件:
Make sure that the URL for your admin media is configured in the settings for ADMIN_MEDIA_PREFIX:
Also, if you're using django's development server, see the docs on How to serve static files: