0

When this one runs everything goes fine:

(r"^newobject$", "views.myobjects.newobject"),

All the CSS + JS files are properly fetched from:

static/css/...
static/js/...

When this one runs:

(r"^mybjects/(([a-z]|[A-Z]|[0-9])+)$","views.myobjects.loadobject"),

All the css and JS files that are being fetched, are run trough the urlpatterns and are returning my defailt page:

(r"", 'views.main.index'),

This makes all my CSS and JS code to actualy be HTML. My guess is that i'm giving some noob mistake. Is there any common reason why this should happen? And how to fix it?

Edit:

Css example:

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

JS example:

<script src="static/js/libs/date.js" type="text/javascript"></script>
fmsf
  • 36,317
  • 49
  • 147
  • 195
  • Can you post the lines of code that link to your js and css files from your templates? – Michael Patterson Apr 03 '10 at 23:32
  • there you go.I'm just puzzled because they work nice on the first function. (I've even copy pasted the code of the newobject into the loadobject but the problem persists) – fmsf Apr 03 '10 at 23:37

1 Answers1

3

See the difference:

  • when you access *some url*/newobject the static/css/style.css refers *some url*/static/css/style.css*
  • when you access *some url*/newobject/whatever the static/css/style.css refers *some url*/newobject/static/css/style.css*

If your URL will always be floating around in depth, include your javascript and CSS using URLs relative to the server root (start them by /) instead of relative to the current dir.

Miguel Ventura
  • 10,344
  • 2
  • 31
  • 41