1
I have a website in Django where I want to serve the favicon.ico
- which being a static file, is in STATIC_URL/caminho/pro/favicon.ico
. It is possible to do this directly from urls.py
? (i.e. without having to write a view just for that)
I found that answer in Soen that tells you how to map from one pattern to another [named], but that’s not what I need: I want to map from one pattern to a static URL. Something like:
url(r'^favicon.ico$', view_que_serve_a_partir_do_STATIC_ROOT_ou_redireciona_pro_STATIC_URL),
Is it possible? And if not, what would be the least laborious alternative?
P.S. I am using Django 1.4.14, in Python 2.6.0 (and not, due to restrictions in my environment can not update to a newer version...)
Why not use
{% static 'path' %}
in the template?– Paulo
@Orion because it has no template... It is the browser itself that requests the
/favicon.ico
, regardless of what is on the page (although I recently discovered that it is possible to specify the favicon by a tag on thehead
page, making this requirement unnecessary)– mgibsonbr
I didn’t even know that the browser requested without indicating on
head
from the page the icon’s address, so I found it strange not to use the{% static 'path' %}
, but it’s explained.– Paulo