#11 Django tutorials | Static Files - 2

preview_player
Показать описание


Django is a high-level Python-based free and open-source web framework, which follows the model-view-template (MVT) architectural pattern.
It is maintained by the Django Software Foundation (DSF).
Django's primary goal is to ease the creation of complex, database-driven websites.
Some well-known sites that use Django include the Public Broadcasting Service, Instagram, Mozilla, The Washington Times, Disqus, Bitbucket, and Nextdoor.

Editing Machines & Monitors :

Facebook:

Subscribe to our other channel:

Donation & Support:
PayPal Id : navinreddy20
Patreon : navinreddy20
Рекомендации по теме
Комментарии
Автор

"As a programmer, you spend less time in coding and more in debugging agree more... :D

prasad
Автор

@Chaudhry Iftikhar Hussain
<-- this guy is amazing
Those of you getting error, not able to add background image just do the following:

to

and for images use static like this way <img src="{% static 'images/beach.svg' %}"

This worked for me...

onkkkar
Автор

Remember
STATIC_ROOT is predefined variable so dont change its name like static_root

vijayaiyappa
Автор

Sir question, when you already put the static files on the static folder then you edit the settings.py and then do the command with manage.py collectstatic,
What if you need to edit your css file? Or add another image?
You’ll do the edit with the assets folder directly? Or you’ll add the new image or edit the css files in the static folder then do the command manage.py collectstatic again to migrate the changes to the assets folder?

kadel
Автор

Thank you so much sir for making the tutorial on Django. Please make it complete as soon as possible. I love the way you teach.

shariqueshaikhh
Автор

i am getting error in index.html... it is unable to read {%static %} part even after loading {% load static %} also

vamshikrish
Автор

I am getting errors of image not found. you should have uploaded full video while editing the whole process.

Nachiketa_TheCutiePie
Автор

I started learning Django a few months back and stopped at your 5th or 6th video, because of a few issues I got and I was unable to solve it. But again I started this series and solved each and every issue I am facing while learning. Thank you Naveen Reddy for helping us learning all these technical content with so easiness. We all appreciate your hard work.

asishraz
Автор

Good tutorials always!!! But please upload a combined video on static files with proper steps without errors... Errors make me confuse 😅 BTW when r u uploading next video 😁

manpreetkaur
Автор

Hi Sir, {% load static %} is showing error in <!DOCTYPE html> , how to resolve it .

palaksharma
Автор

If you guys are facing problems in loading the image use this code it works...

alphonseprakash
Автор

for backgroudn images just write static like

waqar
Автор

if you couldn't display the change after applying all the things. then solution, you should add app name to settings file("INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'trevallo',
]

rumeshkodithuwakku
Автор

Those of you getting error, not able to add background image just do the following:

to

and for images use static like this way <img src="{% static 'images/beach.svg' %}"

This worked for me...

fxchaudhry
Автор

Hi. When you use the command collectstatic (min @) it just copy the files in static to a folder named assets. Why?
What is this folder for? Why you don't use it after that? What's the difference between static and assets folders?

LeaTex
Автор

Problem solved! I suggest to add static tag to all images, follow the instructions made below and code will be working fine!!

Before changes: <div class="background_image"

After changes: <div class="background_image" style="background-image: url({% static 'images/home_slider.jpg' %})"></div>

abhishekgandhewar
Автор

step by step I have done all the things.But the browser can not load the static files.Inspecting element the .css file is automatically being blank.

arnabdas
Автор

Once "assets" folder is created, can we delete the static folder? asking coz why keep the same files in 2 folders occupying memory more space?

angelsunshine
Автор

Please Help Me guys I am getting this kind of errors in my console..

14Refused to apply style from '<URL>' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
owl.carousel.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
bootstrap.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
popper.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
isotope.pkgd.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
jquery-3.2.1.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
jquery.scrollTo.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
easing.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
parallax.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
beach.svg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
custom.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
wallet.svg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
suitcase.svg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
destination_1.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
destination_3.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
destination_2.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
popper.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
destination_4.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
destination_5.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
destination_6.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
news_1.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
bootstrap.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
news_2.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
news_3.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
sign.svg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
trekking.svg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
owl.carousel.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
around.svg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
home_slider.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
intro.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
travello.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
isotope.pkgd.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
jquery.scrollTo.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
easing.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
parallax.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
custom.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)

WhySoPythonic
Автор

Please Help Me guys I am getting this kind of errors in my console..

14Refused to apply style from '<URL>' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
owl.carousel.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
bootstrap.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
popper.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
isotope.pkgd.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
jquery-3.2.1.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
jquery.scrollTo.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
easing.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
parallax.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
beach.svg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
custom.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
wallet.svg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
suitcase.svg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
destination_1.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
destination_3.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
destination_2.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
popper.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
destination_4.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
destination_5.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
destination_6.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
news_1.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
bootstrap.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
news_2.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
news_3.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
sign.svg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
trekking.svg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
owl.carousel.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
around.svg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
home_slider.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
intro.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
travello.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
isotope.pkgd.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
jquery.scrollTo.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
easing.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
parallax.min.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
custom.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)

WhySoPythonic