简体   繁体   English

为什么我不能使用Django管理应用程序的资源

[英]why i can't use django admin app's resource

i want to reuse django's contrib "admin" resource in my project, "admin" has a static directory, which is "static/admin/image/selector-icons.svg" i want to reuse. 我想在我的项目中重用django的贡献“ admin”资源,“ admin”有一个静态目录,我想重用的是“ static / admin / image / selector-icons.svg”。

i have such settings.py: 我有这样的settings.py:

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

i also tried: 我也尝试过:

STATICFILES_DIRS = (
    os.path.join(PROJECT_ROOT,'static'),
    file path of admin's static
)

failed again. 再次失败。

"admin" can use "static/admin/image/selector-icons.svg" in its "widgets.css" like “ admin”可以在其“ widgets.css”中使用“ static / admin / image / selector-icons.svg”,例如

.selector-add {
    background: url(../img/selector-icons.svg) 0 -96px no-repeat;
    cursor: default;
}

but i cant do like that in my project like this: 但是我不能像这样在我的项目中这样做:

.selector-add {
    background: url(admin/img/selector-icons.svg) 0 -96px no-repeat;
    cursor: default;
}

console of chrome said 404 error! chrome控制台表示404错误! but

.selector-add {
    background: url(admin/img/selector-icons.gif) 0 -96px no-repeat;
    cursor: default;
}

worked. 工作了。

and i find in "admin" render to html, "selector-icons.svg" will be transform to "selector-icons.gif", just like below picture: 我发现在“ admin”渲染为html中,“ selector-icons.svg”将被转换为“ selector-icons.gif”,如下图所示: CSS以红色圆圈显示“ selector-icons.gif”,而不是“ selector-icons.csv”

so my question is: 所以我的问题是:

first: how to reuse "admin" resource? 第一:如何重用“管理员”资源?

second:why "selector-icons.svg" to "selector-icons.svg"? 第二:为什么将“ selector-icons.svg”改为“ selector-icons.svg”?

The icons have been changed from to svg in Django 1.9, which hasn't been released yet (see ticket 20597 ). 图标已在Django 1.9中从svg更改为svg,尚未发布(请参见票证20597 )。

On older versions of Django, including the current release 1.8, the icons are gifs. 在较早版本的Django(包括当前的1.8版)上,图标为gif。

You could either use the gifs until you upgrade, or if you really need the svgs now, you could clone the repository and add the svgs to your static files. 您可以使用gif直到升级,或者如果现在确实需要svg,则可以克隆存储库并将svg添加到静态文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我不能通过admin /?将jpg文件上传到我的Django应用程序? - Why can't I upload jpg files to my Django app via admin/? 为什么我不能使用'django-admin.py makemessages -l cn' - Why can't I use 'django-admin.py makemessages -l cn' 为什么我不能运行 django-admin? - Why can't I run django-admin? 为什么我不能在Visual Studio外部运行django应用程序? - Why can't I run django app outside visual studio? 如何将表中的所有对象用作标签 - 在Django的Admin中输入模型? - How can I use all objects in a table as a label - input in a model in Django's Admin? 无法让django-admin启动新项目。 寻找我删除的旧项目 - Can't get a django-admin to start a new project. It's looking for an old project I deleted 离开内置的runserver后,为什么Django找不到我的管理媒体文件? - Why can't Django find my admin media files once I leave the built-in runserver? 为什么自定义用户model后无法进入django的管理界面? - Why can't I enter the admin interface in django after costumizing the user model? 为什么我不能将__getattr__与Django模型一起使用? - Why can't I use __getattr__ with Django models? 为什么我不能在 django 站点的 Javascript 中使用 Jinja? - Why can't I use Jinja in Javascript for a django site?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM