lsaturn
lsaturn

Reputation: 145

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.

i have such 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

.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

.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: in red circle the css shows "selector-icons.gif", not "selector-icons.csv"

so my question is:

first: how to reuse "admin" resource?

second:why "selector-icons.svg" to "selector-icons.svg"?

Upvotes: 0

Views: 975

Answers (1)

Alasdair
Alasdair

Reputation: 309039

The icons have been changed from to svg in Django 1.9, which hasn't been released yet (see ticket 20597).

On older versions of Django, including the current release 1.8, the icons are gifs.

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.

Upvotes: 1

Related Questions