We have an application running built on python/django. I get emails whenever there is a missing link (404) or a server error (500). I've noticed that i get a number of links that looks something like this:
Referrer: http://www.mywebsite.com/model/
Requested URL: /model/js/modernizr-1.7.min.cb14102011.js
User agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; GTB7.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
IP address: 41.2.246.84
The issue is the requested url. It requests the js file relative to the current dir, rather than the absolute dir. What makes it bizarre is that I can't reproduce it, and it happens a handful of times a day, even though there are many different users on the site. The consequence of the missing links also sometimes causes 500 errors, depending on the url (due to the django url structure I've defined for the application).
Has anybody seen this kind of issue before? Is there anything that I should check for that might resolve this issue?
Edit: The js files are accessed through http://www.mywebsite.com/static/js/ The same configuration applies for css files. On further investigation it seems that the 'static' part gets dropped from the url.
Edit (2) I made a mistake yesterday. not only does the {{ STATIC_URL }} not pull through as defined in the settings file, it is replaced with the current (relative) url. I.e, in the original post "model" should be "static", but its not replaced as such. I'm still at a loss as to why this happens.
Thanks Dennis and Jordan. Your comments helped me a lot.
For my scenario I noticed the problems only happens on 1 url. Since many of the templates use the same base template. I ruled out a base template problem. I also checked the views of the url to see that the context was added correctly (since without context the STATIC_URL variable might not pull through). All good.
I also only saw IE7 in the logs. When I looked at the template I noticed an extra closing " (ie class="bogus"" ). I think that extra quote messed up the template, and IE7 then had trouble rendering the rest of the template.
I've made the changes in production so am not 100% sure that I've fixed the problem, but I'll know within a day or so.
Edit: The answer, I've realised, lies in the fact that if there is a coding problem (ie the server throws a 500), then the context doesn't get loaded correctly, and so the STATIC_URL doesn't get populated. This also means that each 500 error will have a corresponding 404 error for any files loaded from STATIC_URL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With