Django {% load staticfiles %} vs {% load static %} - Which One to Use?

Опубликовано: 30 Май 2019
на канале: Jarad Python
7,027
102

When do you use {% load static %} vs {% load staticfiles %}? What's the difference between {% load static %} and {% load staticfiles %}?

That's what I aim to answer in this video.

Whenever you use load staticfiles or load static, it loads a Django template tag. In-order to use this template tag, you have to set up your static file directories. After that, you import the CSS, Javascript or Images from these locations.

The difference between {% load staticfiles %} vs {% load static %} and which one you should use comes down to what version of Django you have. Before Django 1.10, you would use {% load staticfiles %}. From Django version 1.10 and up to 2.1, you have the option to use either {% load staticfiles %} or {% load static %}. From Django 2.1 and onward, {% load staticfiles %} is deprecated in favor of {% load static %}.

Therefore, if you have the latest version of Python, simply use {% load static %} and not {% load staticfiles %}.

Helpful links:
https://code.djangoproject.com/ticket...
https://stackoverflow.com/questions/3...
https://docs.djangoproject.com/en/1.9...
https://docs.djangoproject.com/en/2.2...
https://docs.djangoproject.com/en/dev...
https://docs.djangoproject.com/en/2.2...

#Python #Django


Смотрите видео Django {% load staticfiles %} vs {% load static %} - Which One to Use? онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал Jarad Python 30 Май 2019. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 7,027 раз и оно понравилось 102 посетителям.