I am stuck for 2 hours about STATIC_URL and STATIC_ROOT when I try to run webapp on my server in webfactional.
when I load a web page, all requests work well, except that any link with {{STATIC_URL}} is working or loading.
So the general error that occurs in firebug is this:
GET http://mydomain/static/extras/h5bp/js/libs/modernizr-2.5.3.min.js 500 (Internal Server Error)
My setup:
urls.py I did nothing and there was nothing about static files.
settings.py DEBUG = False
STATIC_ROOT = '/home/mydomain/webapps/static_app/' STATIC_URL = 'http://mydomain/static/' STATICFILES_DIRS = ()
views.py view example
@csrf_exempt def IndexView(request): try: request.user.is_authenticated() except AttributeError: return render_to_response('index.html', {'request': request,}, context_instance=RequestContext(request)) return render_to_response('index.html', {'request': request, 'profile' : request.user}, context_instance=RequestContext(request))
index.html code portion not found
<script src="{{ STATIC_URL }}extras/h5bp/js/libs/modernizr-2.5.3.min.js"></script>
Ok, I follow all the points: https://docs.djangoproject.com/en/1.4/howto/static-files/ and this is another one: http://docs.webfaction.com/software/django/getting-started. html
I use the correct installed applications, middlewares, template_contexts.
If I am missing something, help me figure it out.
Thanks in advance!
- change
I have to say if I just changed DEBUG = True will work fine.
because on urls.py I have this piece of code:
if settings.DEBUG: # static files (images, css, javascript, etc.) urlpatterns += patterns('', (r'^media/(?P<path>.*)/$', 'django.views.static.serve', { 'document_root': settings.MEDIA_ROOT}))