Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Django loading static files
#7
(Oct-13-2017, 07:54 AM)hbknjr Wrote: you should have pasted the code here and not a screenshot link.

Django gives a real helpful traceback of error when debug is set to True. You can find the problem there.

By the way, in development Django serves the static files by collecting all of them(from different apps) in a single folder static. So your path needs to be according to that.

It should be href='{% static "test2.css" %}'.
for folder structure:

'static'/
    'test2.css'
It is a common practice to put the static files in a folder with the same name of the app(which you have done). For that, your folder structure should be.

'static'/
    'website2'/
        'test2.css'

I thought it was useful to include a screenshot so you could see the way my folders are structured, but I'll keep that in mind next time!
I followed your suggestion but it doesn't seem to work yet. when I go to the page on my local server I still only get HTML without CSS. The terminal tells me:

[13/Oct/2017 09:50:43] "GET /hello/ HTTP/1.1" 200 847
[13/Oct/2017 09:50:43] "GET /static/test2.css HTTP/1.1" 404 1640

is that the error message you reffered to?

(debug is set to true in the settings.py file)
Reply


Messages In This Thread
Django loading static files - by Dutchpy - Oct-11-2017, 03:03 PM
RE: Django loading static files - by nilamo - Oct-11-2017, 09:51 PM
RE: Django loading static files - by Dutchpy - Oct-12-2017, 07:49 PM
RE: Django loading static files - by buran - Oct-12-2017, 09:05 PM
RE: Django loading static files - by Dutchpy - Oct-12-2017, 09:40 PM
RE: Django loading static files - by hbknjr - Oct-13-2017, 07:54 AM
RE: Django loading static files - by Dutchpy - Oct-13-2017, 09:57 AM
RE: Django loading static files - by hbknjr - Oct-13-2017, 10:25 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question [Solved] Private static files SpongeB0B 1 1,089 Jul-16-2022, 05:36 AM
Last Post: SpongeB0B
  Flask, Display a picture outisde the static SpongeB0B 6 15,724 Aug-29-2020, 05:15 PM
Last Post: nilamo
  SHow image in a static link of Django pycada 3 2,584 Mar-04-2020, 01:50 AM
Last Post: pycada
  Django problem with files menator01 1 1,977 Jan-05-2020, 04:20 PM
Last Post: menator01
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,369 Jun-30-2019, 12:21 AM
Last Post: scidam
  django herf not loading right LK1097 0 2,103 May-31-2018, 06:59 AM
Last Post: LK1097
  first django site-ms word/pdf files jon0852 1 4,409 Nov-19-2017, 08:39 PM
Last Post: homayoon_hashemi

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020