0

I'm using Django 1.4

My static files don't seem to be running or {{ STATIC_URL }} is wrong in the html file.

In the settings, I have the static files loaded:

STATICFILES_DIRS = (
    'C:/Users/dtc/Documents/Eclipse/java_applet/applet',
)

STATIC_ROOT = ''

STATIC_URL = '/static/'

In url.py I have:

urlpatterns += staticfiles_urlpatterns()

In the html file, I have:

<html>
<title>The Hello, World Applet</title>

<img src="{{ STATIC_URL }}tets.png" />

<applet code="{{ STATIC_URL }}HelloWorldApplet.class" width="320" height="120">
If your browser was Java-enabled, a "Hello, World"
message would appear here.
</applet>

</html>

Now, when I runserver, I can download the static files from localhost:8000/static/file which means it should be there right? But when I load the page, neither the applet or the image is showing up. All I'm trying to do as an endgoal is to run an applet on my dev server but I can't seem to figure out why {{ STATIC_URL }} isn't working(I even added a backslash after it in case that was the reason).

dtc
  • 1,774
  • 2
  • 21
  • 44
  • can download the static files from localhost:8000/static/file? have you check the source code of rendered html? – iMom0 Oct 10 '12 at 01:08
  • im guessing you meant the view. yeah, that's right. i was missing requestcontext – dtc Oct 10 '12 at 18:27

1 Answers1

1

Look at the RequestContext class, this is probably what you're looking for. See this answer on SO as well.

Community
  • 1
  • 1
F.X.
  • 6,809
  • 3
  • 49
  • 71
  • thanks, i skipped seeing this because i thought it was automatically added in AND the instructions page for django puts that in an extra section of their documentation for managing static files. – dtc Oct 10 '12 at 18:29
  • Yeah, the way Django does it is kinda... not intuitive at first, and you're definitely not alone in that ;) – F.X. Oct 10 '12 at 18:36