Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Django Basics Django Templates Static Assets

Brian Anstett
Brian Anstett
5,831 Points

Static CSS page can not be found when working with Pycharm

I have been using Pycharm instead of workstations throughout the "Django Basics" course and everything has been working exactly as supposed to up until the first static assets discussion. I currently am unable to find the static CSS page and get the ""GET /static/css/layout.css HTTP/1.1" 404 1769" message in my logs along with a similar error in the console when inspecting the elements.

At first I assumed it was a coding error and went on detective mode in search for any errors. With no luck, I downloaded Kenneth's code from the teacher notes and have the same problem which leads my to believe that there is something in Pycharm that is different (as the use of Pycharm is the only difference) I really hope I can get some help with this as I'm really enjoying this course and was hoping to practice using Pycharm instead of workspaces to simulate a more "in the wild" experience.

To aid in the debugging, I have taken screen shots show the errors, permissions, file structure, etc.

https://snag.gy/R43KNm.jpg

2 Answers

Ryan S
Ryan S
27,276 Points

Hi Brian,

One thing that jumps out is that you are linking to "layout.css" in your template, but the actual name of your css file is "layouts.css". I think that might be the cause of your 404 error - it is unable to find layout.css because it doesn't exist.

The other thing I notice is that with Django 1.10, your STATICFILES_DIRS should be a list enclosed with square brackets [], not a tuple. This was a change that happened in a later version than the one Kenneth is using. You can see the example in the docs.

However, this change doesn't seem to affect the outcome when I swap the two types of brackets (or at least at this stage it doesn't). But it's just something to keep in mind.

Hope this helps.

Brian Anstett
Brian Anstett
5,831 Points

Thank you Ryan, That solved my problem. I very much appreciate it. Merry Christmas