0

I'm running django on webfaction, and am having trouble implementing my css files. A sample html file I have is:

<html>
<head>
</head>
<h1>
Poll
</h1>
<body>
<link rel="stylesheet" type="text/css" href="/home/shop/webapps/django/shop/static/index.css" />
<form name="Search bar" action="/search/results/p=1/" method="post">
{% csrf_token %}
UserId: <input type="text" name="UserId" /><br><br>
<input type="text" name="Keyword" />
<input type="submit" value="Search" />
</form>

</body>
</html>

The exact same file runs fine on my local server, but doesn't work on webfaction. I was wondering if anyone has an idea of whats going wrong.

Thanks!

iman453
  • 9,105
  • 16
  • 54
  • 70

2 Answers2

3

Why are you referencing this stylesheet absolutely?

<link rel="stylesheet" type="text/css" href="/home/shop/webapps/django/shop/static/index.css" />

Just refer to the static directory, as it takes care of static file loading for you:

<link rel="stylesheet" type="text/css" href="/static/index.css" />

If you'd like to know how to set up your media folder, look here: Django: how do you serve media / stylesheets and link to them within templates

Community
  • 1
  • 1
Blender
  • 289,723
  • 53
  • 439
  • 496
  • Thank you for your reply. So in this example, in my settings.py file I woul have STATIC_URL = '/home/shop/webapps/django/shop' right? I'm not sure why it's not working. – iman453 Apr 21 '11 at 04:54
1

You can't reference a local file. /home/shop/webapps/django/shop/static/index.css is your hard drive location.

You need to put it in a media folder and point to it some how. Django deployment via modwsgi is how i do it.

EDIT

a quick search on webfaction got me: http://docs.webfaction.com/software/django/getting-started.html#serving-static-media

if you put it in a media folder in your application folder you need something like:

/home/username/webapps/django_application/media/

For standard media/static files

James Khoury
  • 21,330
  • 4
  • 34
  • 65