I have facing this issue when i am trying to give favicon to my admin portal it was working completely fine till DEBUG
was True
. When I switch to DEBUG=False
it start showing me this error which i mention in tittle.
here is my code :
templates/admin/base_site.html
{% extends "admin/base_site.html" %}
{% load static %}
{% block extrahead %}
<link rel="shortcut icon" href="{% static '/img/favicon.ico' %}" />
{% endblock %}
settings.py
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static')
]
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
MEDIA_URL = '/media/'
In debug it worked smoothly now it shows me error 400 in browser and in terminal:
raise SuspiciousFileOperation( django.core.exceptions.SuspiciousFileOperation: The joined path (D:\img\favicon.ico) is located outside of the base path component (D:\Social_login\staticfiles)
{% extends "admin/base_site.html" %}
{% load static %}
{% block extrahead %}
<link rel="shortcut icon" href="{% static 'img/favicon.ico' %}" />
{% endblock %}
It solved my problem just with the above code snippet.