52👍
✅
You have to use context_instance=RequestContext(request)
in your render_to_response
, for example:
return render_to_response('my_template.html',
my_data_dictionary,
context_instance=RequestContext(request))
Or use the new shortcut render
As Dave pointed out, you should check if django.core.context_processors.static
is in your TEMPLATE_CONTEXT_PROCESSORS
variable in settings.py. As the docs said, it`s there by default.
3👍
It is not recommended to directly use the STATIC_URL
variable. See the accepted answer in this question
Instead of
{{STATIC_URL}}stylesheets/tabs.css
use
{% load staticfiles %}
{% static 'stylesheets/tabs.css' %}
- [Django]-CORS: Cannot use wildcard in Access-Control-Allow-Origin when credentials flag is true
- [Django]-Why are read-only form fields in Django a bad idea?
- [Django]-Bad request 400: nginx / gunicorn
0👍
I have the same problem, solved like this:
in settings.py
add:
django.template.context_processors.static
here:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': TEMPLATE_DIRS,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.template.context_processors.static',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
- [Django]-Adding REST to Django
- [Django]-VSCode terminal shows incorrect python version and path, launching terminal from anaconda works perfectly
- [Django]-How to overcome 'Coudn't find that formation' error when adding web dynos to Heroku django app?
Source:stackexchange.com