Use {% load static %} instead of {% load staticfiles %} in templates

Starting with Django 1.10, it is preferable to load the static template
tag library instead of staticfiles. If django.contrib.staticfiles is in
INSTALLED_APPS, the static template tag library will use the staticfiles
app to determine static paths. For additional details, see:

https://docs.djangoproject.com/en/dev/releases/1.10/#django-contrib-staticfiles

> The static template tag now uses django.contrib.staticfiles if it’s in
> INSTALLED_APPS. This is especially useful for third-party apps which
> can now always use {% load static %} (instead of {% load staticfiles
> %} or {% load static from staticfiles %}) and not worry about whether
> or not the staticfiles app is installed.

The staticfiles template tag library will be deprecated and removed in a
future Django version.
This commit is contained in:
Jon Dufresne 2018-01-25 18:11:09 -08:00
parent 1664588500
commit a25266861a
7 changed files with 6 additions and 7 deletions

View File

@ -395,7 +395,7 @@ Once the API documentation URLs are installed, you'll be able to include both th
/static/rest_framework/js/coreapi-0.1.1.js /static/rest_framework/js/coreapi-0.1.1.js
/docs/schema.js /docs/schema.js
--> -->
{% load staticfiles %} {% load static %}
<script src="{% static 'rest_framework/js/coreapi-0.1.1.js' %}"></script> <script src="{% static 'rest_framework/js/coreapi-0.1.1.js' %}"></script>
<script src="{% url 'api-docs:schema-js' %}"></script> <script src="{% url 'api-docs:schema-js' %}"></script>

View File

@ -1,4 +1,4 @@
{% load staticfiles %} {% load static %}
{% load i18n %} {% load i18n %}
{% load rest_framework %} {% load rest_framework %}

View File

@ -1,4 +1,4 @@
{% load staticfiles %} {% load static %}
{% load i18n %} {% load i18n %}
{% load rest_framework %} {% load rest_framework %}

View File

@ -1,4 +1,4 @@
{% load staticfiles %} {% load static %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>

View File

@ -1,4 +1,4 @@
{% load staticfiles %} {% load static %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>

View File

@ -1,5 +1,5 @@
{% load rest_framework %} {% load rest_framework %}
{% load staticfiles %} {% load static %}
<pre class="highlight javascript hide" data-language="javascript"><code>{% code html %}<!-- Load the JavaScript client library --> <pre class="highlight javascript hide" data-language="javascript"><code>{% code html %}<!-- Load the JavaScript client library -->
<script src="{% static 'rest_framework/js/coreapi-0.1.1.js' %}"></script> <script src="{% static 'rest_framework/js/coreapi-0.1.1.js' %}"></script>
<script src="{% url 'api-docs:schema-js' %}"></script>{% endcode %}</code></pre> <script src="{% url 'api-docs:schema-js' %}"></script>{% endcode %}</code></pre>

View File

@ -1,5 +1,4 @@
{% extends "rest_framework/base.html" %} {% extends "rest_framework/base.html" %}
{% load staticfiles %}
{% load rest_framework %} {% load rest_framework %}
{% block body %} {% block body %}