If you're running Django 3 and were on an older version before, you need to replace: {% load static from staticfiles %} or {% load staticfiles %} with just: {% load static %}
if the file doesn't show up, please make sure you added the finishing coma in the tuple STATICFILES_DIRS = ( os.path.join(BASE_DIR,'assets'), ) this is in the settings.py
u are awesome :) i was so confused and scared about django but the more i advance the more it getting clear and simple thank u , keep creating such perfect series plz :)
I really like your tutorial videos. Each video/Topic is short, and gets straight to the point. I know this version may be a little outdated, but I prefer to go by your videos!
I'm still going, but this series is exceptional. I have been using Django for about 2 years by mostly modifying the starter app that comes in Visual Studio (haters gonna hate) but I never understood it. This has filled in all the blanks. Can't thank you enough.
At first i did it.But it still didn't work. But when i put the static folder inside the article app,then it works . I am still trying to find where the problem was?
What a great tutorial, thank you. Succinct, clear and quick! I had three issues that others may have had. 1. You need to "import os" at the top of the settings.py file 2. When trying to access my admin site after these changes I had an 'incorrect padding' error. I found a solution on stack overflow - you need to download a more recent version of Django (pip install django==3.1.1) 3. {% load static from staticfiles %} did not work. I found a quick fix on stackoverflow. Just change it to {% load static %} and it works really well.
Hello ninja, first of all, great job with the tutorials, they are amazing! I only have one question, Are you planning in the near future to show us how to serve static files for production? i would really appreaciate. xD
for some who got stucked with the STATICFILES_DIR and File Not Found problem, I hope you didnt repeat the same silly mistake i did, which is the 'assets' folder i put it wrongly in the sub 'Djangonautic' folder, in which it supposed to be in the base 'Djangonautic' folder.
I wish you could make Django/AWS for production a mini series or a simple tutorial Shaun! Not many people guide for industrial production level basis..
Hi, thank you for the tutorial. I am facing issue while loading my static/styles.css file on browser. It says Not Found The requested URL /static/styles.css was not found on this server. I have followed same procedure line by line. I have not missed "," after staticfiles_DIRS tuple. Please help
What worked for me was to use a list, and not a tuple, like this: STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'staticfiles'), ] You see, he says you can use a list or a tuple, and maybe it works in older django versions, but for some reason i had to use a list, tuples don't work for me in this, also i named my folder different (saticfiles), but that has nothing to do with the error. I hope this help you.
Thanks for the tutorials! I got some question, how do I access another static file in another directory from my css file? the curly braces seems to cause trouble when I used {% load static %}
Can I ask you something? What’s the benefit of Django jargon when we can do things in a lot easier fashion using the same old html,php,Css JavaScript etc? I don’t see any point of this Django other than causing confusions and making simplest of things a lot harder to do. Same as mvc I never saw any point in that too. There is absolutely no way any one can remeber so many things to do in different files and folders at the place of work.
Hi there. Your videos are really helpful! However, i am having problem with my static files. the CSS file does not seem to be working. How can i make it work?
If your changes in css is not reflecting on web page then it might be because of your browser is caching css file in the browers, Try refreshing web page by holding ctrl or shift, this should work.
Beautiful tutorials!!!!! I just got one issue, everything seems to work but, I didn't get the same font style. Mine is sort of like Times New Roman. Please help! :(
what's up dude? I have a question. How do we use static files (css file for example) that is intended only for a specific app? Where do we put these static files?
Oh my f!!! FINALLY!!! At 2AM guys!! 2 fucking AM I figured out the problem. Should be: STATICFILES_DIRS = ( os.path.join(BASE_DIR, "assets/styles.css") ) Django wants to know the path and not the location of the folder. Now I'm wondering what will happen if there is more than one file in there. This is frustrating me!
Hi, I have really strange problem with static files. In my css file i can't affect body at all. My css file is connected for sure because i can change other things like f.e. h1 but body won't work no matter what I am doing.
i was rolling to make it work but it work for me after change this line of code its not a tuble its a list ( ) => [ ] STATICFILES_DIRS = [ os.path.join(BASE_DIR,'assets'), ]
If you're running a more recent version of django, use this instead of the os.path.join method. BASE_DIR goes into the base project folder, it then looks for a folder called static. STATICFILES_DIRS = [ BASE_DIR / 'static' ]
@@ninjatribble7961 cant remember what I did to solve this issue, but I then ran into another issue with user media and this vid helped me out ruclips.net/video/QC2cLkHoXLk/видео.html
@@asiful_alam yeah actually. It turns out I just forgot to remove the DOCTYPE HTML thing at the beginning of the template. It worked after that. You should try it. So funny how I literally spent hours trying to fix such a tiny problem
Everything is working fine but the font. I downloaded the entire Ubuntu family yet still displays a Times New Roman font. Not every font works tho (Arial works but not comic sans?)
If you are still having trouble loading the /static/styles.css page - try restarting. I tried every fix on here and nothing was working. Restarted and it worked *face palm*
in my case it did't work with {%load static from staticfiles%} it worked with {%load static %} but in your case it work with staticfiles . why its happend
It looks that it's getting trickier and trickier... How do you know what to IMPORT and FROM to import it? And i think you need to know 2 things: 1 - That there is no such functionality in Django by default; 2 - That there is SOMETHING that you can import to get that needed functionality.
Hello, I can' get past the "Directory indexes are not allowed here" on the Get static call to the server. It seems to me i've done everything right. I've gone as far as copying netninja's code from github into my own script and reviewing the django documentation they have on the web. github.com/ATajadod94/django-practice-project/tree/master/practice/practice my folder is uploaded on github which contains both the setting and url python files. If anyone can help that would be great.It seems to read the static page so i'm doing at least something right , but obviously not enough. Also, when I try to import static into my tempelate, it doesnt read it, I assume for the same reasons.
If you're running Django 3 and were on an older version before, you need to replace:
{% load static from staticfiles %} or {% load staticfiles %}
with just:
{% load static %}
thanks man!
Thanks Elias.
Thanks man
this comment needs to be pinned.
That’s true
bro just wanted to say that 6 years later, your django tutorials are still the best around! 🤗
I appreciate that! :) thank you
Okay, this is indeed the BEST DJANGO tutorial in the universe. Thanks a lot for creating series.
Thanks so much! :)
in DJANGO 3 , in settings.py use the following STATICFILES_DIRS = [
BASE_DIR / "assets",
]
Not all heroes wear capes.
AWS/Django for production mini-series +1
I agree
Please Shaun
🙏
it would be awesome
Please sir do it
if the file doesn't show up, please make sure you added the finishing coma in the tuple
STATICFILES_DIRS = (
os.path.join(BASE_DIR,'assets'),
)
this is in the settings.py
Django seem to not recognize the "os" part. It has a yellow sqiggly line underneath... it says "os" is not defined ???? help?
@@VS257 Import os in settings.py file
@@VS257 STATICFILES_DIRS = [
BASE_DIR / "assets",
]
Thank you very much for this series!
I'd like to add that I'd be very interested in a Django for production + AWS series.
u are awesome :) i was so confused and scared about django but the more i advance the more it getting clear and simple thank u , keep creating such perfect series plz :)
Your communication skills are the best!! Short, sweet and to the point. Thank you.
I really like your tutorial videos. Each video/Topic is short, and gets straight to the point. I know this version may be a little outdated, but I prefer to go by your videos!
Thank you!! I searched many information, so I find this! I thougt about give up, but with your help I may continue my hobby!
I'm still going, but this series is exceptional. I have been using Django for about 2 years by mostly modifying the starter app that comes in Visual Studio (haters gonna hate) but I never understood it. This has filled in all the blanks. Can't thank you enough.
FIX: in templates {% load static %} in link href="{% static "styles.css" %}"
Thanks man! ;)
Thank you. Use
href="{% static 'styles.css' %}"
to avoid escaping the double quotes though
@@JJnnaatt thanks a lot, does the job neatly :)
best tutorial I've ever seen, I'm loving it.
Thanks for the tutorials, I've learnt a lot from you
If you are having trouble with the static filers thing, try to check the folder level, it has to be on the same level of apps.
Thanks Gabriel, that was the case with my code :)
Thanks bro, I couldn't figure out the issue for like an hour
At first i did it.But it still didn't work. But when i put the static folder inside the article app,then it works . I am still trying to find where the problem was?
Thanks man for making it seem so easy
To get the Ubuntu font you need to add :
to the html file
Thank you so much!
Excellent tutorials ! loved it !!
Really cool explanations! Thank you.
you know what you video helped me a lot, wonderful
awesome tutorial bro. You really know your stuff.
Excellent video and well explained. Thank you!
What a great tutorial, thank you. Succinct, clear and quick!
I had three issues that others may have had.
1. You need to "import os" at the top of the settings.py file
2. When trying to access my admin site after these changes I had an 'incorrect padding' error. I found a solution on stack overflow - you need to download a more recent version of Django (pip install django==3.1.1)
3. {% load static from staticfiles %} did not work. I found a quick fix on stackoverflow. Just change it to {% load static %} and it works really well.
I struggled to find a solution that will work but this has made my work easy, thanks bro a subscribe 4 you and a like on top
No problem Kenny :) thanks for the support!
Thank you very much 😊👍
Hello ninja, first of all, great job with the tutorials, they are amazing!
I only have one question, Are you planning in the near future to show us how to serve static files for production?
i would really appreaciate. xD
for some who got stucked with the STATICFILES_DIR and File Not Found problem, I hope you didnt repeat the same silly mistake i did, which is the 'assets' folder i put it wrongly in the sub 'Djangonautic' folder, in which it supposed to be in the base 'Djangonautic' folder.
well... thank u
THANK YOU. I can't believe how bad the official django documentation is for this simple task.
updated:>>> {% load static %} not use whatever shown on video.
I just loved this tutorial...
Thankyou so much it works and it uses me alot.
It uses u? :P
xD
thanks bro you save my life
I've just set a new personal best for hitting a subscribe button.
Nice to see you again
And what if it's not in the BASE_DIR ?? Like I have it in a separate folder called polls
I wish you could make Django/AWS for production a mini series or a simple tutorial Shaun! Not many people guide for industrial production level basis..
guys, if you have problem with staticfiles, just replace this line to {% load static %}
I have tried everything but this static not working for me. I need your assistance sir.
Same here
Hi, thank you for the tutorial. I am facing issue while loading my static/styles.css file on browser. It says Not Found
The requested URL /static/styles.css was not found on this server.
I have followed same procedure line by line. I have not missed "," after staticfiles_DIRS tuple.
Please help
did you find the answer to your problem? i have the same issue here ):
CaesarGamer did you find the solution i am having the same problem
What worked for me was to use a list, and not a tuple, like this:
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'staticfiles'),
]
You see, he says you can use a list or a tuple, and maybe it works in older django versions, but for some reason i had to use a list, tuples don't work for me in this, also i named my folder different (saticfiles), but that has nothing to do with the error.
I hope this help you.
All of this of course in the settings.py files, i didnt mention it in the reply, sorry xD
thank you, it saved my day :)
sir please can you tell how to use images in static css file for background in django?
Can someone please explain what is "Serve up images" at 0:47?
I am not sure what he meant
the styles.css styles wont load on my articles.html
Thanks for the tutorials!
I got some question, how do I access another static file in another directory from my css file? the curly braces seems to cause trouble when I used {% load static %}
Can I ask you something? What’s the benefit of Django jargon when we can do things in a lot easier fashion using the same old html,php,Css JavaScript etc? I don’t see any point of this Django other than causing confusions and making simplest of things a lot harder to do. Same as mvc I never saw any point in that too. There is absolutely no way any one can remeber so many things to do in different files and folders at the place of work.
Is the font 'Ubuntu' standard or do you have to install it?
Hi there. Your videos are really helpful! However, i am having problem with my static files. the CSS file does not seem to be working. How can i make it work?
found my mistake. Its not ref but rel
Thank you!
If your changes in css is not reflecting on web page then it might be because of your browser is caching css file in the browers,
Try refreshing web page by holding ctrl or shift, this should work.
Pls do aws! I would definitely appreciate that! :)
i like your video very well explained
Thanks :)
Thank you very much :)
Beautiful tutorials!!!!! I just got one issue, everything seems to work but, I didn't get the same font style. Mine is sort of like Times New Roman. Please help! :(
thanks a lot.. it helps a lot..
what's up dude? I have a question.
How do we use static files (css file for example) that is intended only for a specific app? Where do we put these static files?
where is advanced , i am waiting for it .you are the best teacher . i need tips to make my website secure .
thx
I hope, someday I will watch playlist for Django in production :-)
I'm confused
without STATICFILES_DIRS set
how could /static/style.css open on the project
Does django already know about the file ?
Thanks a lot
I am not able to download the course code files of python Django. Can you please help?
hi, i didn't quite understand why i used a folder that contains all our static files
I have tried honestly every single thing in the comments for serving up the static files, and still nothing! I'm am ready to cry!
Oh my f!!! FINALLY!!! At 2AM guys!! 2 fucking AM I figured out the problem.
Should be:
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "assets/styles.css")
)
Django wants to know the path and not the location of the folder. Now I'm wondering what will happen if there is more than one file in there. This is frustrating me!
@Volk Raider THE fuCKIGN COMA
yes, add a comma at the end of the second line like NN did.
Does this work after the Django app has already been deployed?
would be possible to symlink any folder in my system to the myapp/static folder?
you're a LEGEND !!!
Python might make you add a trailing comma in the Touple
But how would you display a picture on the app (instead of it being a background)?
2:16 my friend i didn't get this one can u please simply in few words it will be very much helpful for me to learn django :)
Hi, I have really strange problem with static files. In my css file i can't affect body at all. My css file is connected for sure because i can change other things like f.e. h1 but body won't work no matter what I am doing.
did u manage to solve it? i am facing the same prob as u
@@puteri8 same
I had to take the preceding forward slash out of STATIC_URL: STATIC_URL = 'static/' for it to work... in case anyone else is stuck!
why its not rendering transparent png images?
Hey! I have a problem with my browser loading the css file, I do exactly what you do but it cant load the css file
you've probably solved it, but in my case it was because I missed the comma at the end of the staticfiles tuple
Thank you, sir
i was rolling to make it work but it work for me after change this line of code its not a tuble
its a list ( ) => [ ]
STATICFILES_DIRS = [
os.path.join(BASE_DIR,'assets'),
]
You can still make it a tuple, all you needed is a comma at the end of 'assets'),
that's all
sir this{% for %}----{% endfor %} type is not working for mine. how to solve it? pls help. I tried a lot but failed
I can not get static files in the browser
If you're running a more recent version of django, use this instead of the os.path.join method. BASE_DIR goes into the base project folder, it then looks for a folder called static.
STATICFILES_DIRS = [
BASE_DIR / 'static'
]
Still waiting for Django for production series!!!
Thanks
no idea what im doing wrong. I cant go to a url and work
you can share github link on this project?
I can't even access 127.0.0.1/8000/static without getting a 404 no matter what I do
Same here
@@ninjatribble7961 cant remember what I did to solve this issue, but I then ran into another issue with user media and this vid helped me out ruclips.net/video/QC2cLkHoXLk/видео.html
@@ninjatribble7961 let me know if you have questions, I might remember what I did to fix it
I had a problem loading my styles.css . For some reason they don't apply to the webpage
same here! got any solution??
@@asiful_alam yeah actually. It turns out I just forgot to remove the DOCTYPE HTML thing at the beginning of the template. It worked after that. You should try it. So funny how I literally spent hours trying to fix such a tiny problem
please make new videos with other example and updated django version
year?
Everything is working fine but the font. I downloaded the entire Ubuntu family yet still displays a Times New Roman font. Not every font works tho (Arial works but not comic sans?)
You need to get Ubuntu font from google fonts
How to use with img tag?
If you are still having trouble loading the /static/styles.css page - try restarting. I tried every fix on here and nothing was working. Restarted and it worked *face palm*
God Bless You!!!!
in my case it did't work with
{%load static from staticfiles%}
it worked with
{%load static %}
but in your case it work with staticfiles .
why its happend
I want to use {% load static%} with this;
how i use idk
There's no file in your github repo sir.
Hey, did you select the appropriate branch (select box near the top left)? Just had a look and it's all there.
Thank you.
2:11 tao urlpattern trong url (folder project)
4:06 chinh setting (folder project)
6:00 {{ load_static ... }}trong template
7:17 them file .css
AWS series please...
Life saver !!
loved it
haha was banging my head on my desk trying to figure out what the problem was.
ValueError: not enough values to unpack (expected 2, got 1)
It looks that it's getting trickier and trickier...
How do you know what to IMPORT and FROM to import it?
And i think you need to know 2 things:
1 - That there is no such functionality in Django by default;
2 - That there is SOMETHING that you can import to get that needed functionality.
well in python from import means to import everything compared to just import. I guess just use from import
Hello,
I can' get past the "Directory indexes are not allowed here" on the Get static call to the server. It seems to me i've done everything right. I've gone as far as copying netninja's code from github into my own script and reviewing the django documentation they have on the web.
github.com/ATajadod94/django-practice-project/tree/master/practice/practice
my folder is uploaded on github which contains both the setting and url python files. If anyone can help that would be great.It seems to read the static page so i'm doing at least something right , but obviously not enough. Also, when I try to import static into my tempelate, it doesnt read it, I assume for the same reasons.