RUVIDEO
Поделитесь видео 🙏

042-Adding Static Files-opendir.cloud. #programmer #static #education #pythondjango

📁 Обучение 👁️ 16 📅 01.12.2023

### Adding Static Files in Python Django - The Practical Guide (Lecture 42)

In this lecture, you will learn how to add static files to your Django project. Static files are files that do not change at runtime, such as CSS, JavaScript, and images.

To add static files to your Django project, you will first need to create a `static` directory in your project's root directory. Then, you will need to add the following line to your project's `settings.py` file:




```

python
STATIC_ROOT = os.path.join(BASE_DIR, 'static')


```



This line tells Django where to store your static files.

Once you have added the `STATIC_ROOT` setting, you can start adding your static files to the `static` directory.

To serve your static files, you will need to add the following line to your project's `urls.py` file:




```

python
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

urlpatterns += staticfiles_urlpatterns()


```




This line tells Django to serve static files from the `STATIC_ROOT` directory.

Once you have added the `staticfiles_urlpatterns()` to your `urls.py` file, you can start serving your static files by running the following command:



```

python manage.py runserver


```




Now, you can access your static files by visiting the following URL in your web browser:




```

http://localhost:8000/static/( filename )


```




For example, to access the `index.html` file, you would visit the following URL:




```

http://localhost:8000/static/index.html


```




You can also add static files to your Django templates by using the `static` template tag. The `static` template tag takes the path to the static file as its argument. For example, to include the `index.css` file in your template, you would use the following code:




```

html
{% load static %}
( link rel="stylesheet" href="{% static 'index.css' %}" )


```




This will tell Django to include the `index.css` file in the rendered HTML.

## My Instagram and Telegram channels

Please follow me on Instagram and Telegram for more Django tutorials and tips:

* Instagram: [ https://instagram.com/thecybersecurityclassroom?igshid=MzRlODBiNWFlZA== ]

* Telegram: [ https://t.me/thecybersecurityclassroom ]

Thank you for your support!

**NOTE**
I HAVE USED this ""( ) brackets"" over ""cone brackets""

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «042-Adding Static Files-opendir.cloud. #programmer #static #education #pythondjango», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.