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的contrib“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! but
铬控制台说404错误!但
.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”,如下图所示:
so my question is:
所以我的问题是:
first: how to reuse "admin" resource?
第一:如何重用“admin”资源?
second:why "selector-icons.svg" to "selector-icons.svg"?
第二:为什么“selector-icons.svg”改为“selector-icons.svg”?
1 个解决方案
#1
1
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更改,尚未发布(见票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直到升级,或者如果您现在真的需要svgs,您可以克隆存储库并将svgs添加到静态文件中。
#1
1
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更改,尚未发布(见票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直到升级,或者如果您现在真的需要svgs,您可以克隆存储库并将svgs添加到静态文件中。