#i added a background image and now my i keep getting error 500

57 messages ยท Page 1 of 1 (latest)

oak ore
#

im just starting to learn django and im struggling

#
<!DOCTYPE html>
<head>
    {%load static%}
    <link rel="stylesheet" href="{{static/styles.css}}">
{%load bootstrap5%}
  {% bootstrap_css %}
  {% bootstrap_javascript %}

</head>
<body>

</body>
#
body {
background-image: url('../images/hero.jpg');
}

#

these are the files :(

wary light
oak ore
#

i still have error 500

topaz glacier
#

Did you change href as href="{% static 'styles.css' %}" ?

#

Also check STATIC_URL setting, and your style.css file has correct dir.

oak ore
#

i changed the href
and this is my STATIC_URL

STATIC_ROOT = BASE_DIR / 'staticfiles'

STATIC_URL = 'static/'
#

the css file is in a css folder in static folder dont know if thats important

topaz glacier
#

Then you give me exact error message? Also current css file's path.

oak ore
#

it just show "Server Error (500)"

topaz glacier
#

Can you open the browser's dev tool, and check network tab? Then, give me where error happens.

oak ore
#

how do i open dev tools

topaz glacier
#

For chrome, if you using window, press F12. If you using mac, press command+option+i

oak ore
#

it happens at the ip address

topaz glacier
#

I don't know your project's structure, and with only 500 error message, it's hard to answer. But would you try to change href="{% static 'styles.css' %}" to href="{% static 'css/styles.css' %}"?
I think your current structure seems like below.

static
  - css
    - styles.css
  - images
    - hero.jpg

If so, you need to change like above.

paper sedge
#

Debugging "there was some error" is a unprofessional guess work and waste of time

oak ore
paper sedge
#

What is in the console?

next meteor
#

(the console where you started the development server, it will output errors there)

oak ore
#
[10/Sep/2025 08:08:22] "GET / HTTP/1.1" 500 145
[10/Sep/2025 08:08:22] "GET /favicon.ico HTTP/1.1" 404 140
paper sedge
#

Do you happen to use try-except in it?

#

Only other case to get an exception without any error I can think of is raising it yourself

oak ore
#
from django.http import HttpResponse
from django.template import loader


def landing(request):
    template = loader.get_template('landing.html')
    return HttpResponse(template.render(request))


#

this is my view file

paper sedge
#

something is fishy there

oak ore
#

no its false

paper sedge
#

Why? Set it to true, you WANT debug mode during development

#

And it's default as I mentioned earlier

#

That's why it must be hiding the error

next meteor
next meteor
paper sedge
#

Is it odd? It's just verbose

oak ore
next meteor
#

Based on other w3schools tutorials i have seen they are .... bad

oak ore
#

i turn on debug and it says

In template C:\Users\ldtec\Documents\Coding\Websites\L.D\env\luminary_designs\clients\templates\landing.html, error at line 4

Could not parse the remainder: '/styles.css' from 'css/styles.css'```
oak ore
quartz jasperBOT
paper sedge
paper sedge
oak ore
#

like this??

next meteor
#

yes.

paper sedge
#

I forgot if it needs additional '' around it

next meteor
next meteor
oak ore
#

TypeError: context must be a dict rather than WSGIRequest.

next meteor
#

again, this is probably beacause of you/the w3 tutorial using such low-level code to render the tempalte in your view code .... Imho, throw it all away and start on the official tutorial.