2
votes

It's nearly the same question as this:

Missing bootstrap resources in Django-Rest-Framework

and Django -- Can't get static CSS files to load

So it seems that this may be a more common issue. I checked my settings with the first one and I am not using runserver for the 2nd one.

My settings: DEBUG = False

and installed apps includes: 'django.contrib.staticfiles',

I am running django 1.5 and the latest version of django-rest 2.3.8, using uwsgi + nginx on a Ubuntu 12.04 LTS. The API themselves are being served but the bootstrap and css files are not. When i click into the link in some API and check out the source code for: href = /static/rest_framework/css/bootstrap.min.css

I get the default django 404 url not found.

I think I just missed a step somewhere in the installation but I can't figure out where.

3
This kind of posts should always include the parts of template where you have descibed static files paths. - Odif Yltsaeb

3 Answers

3
votes

I find a simple way to solve it.I guess you must use the uwsgi and nginx. uwsgi can't find the rest_framework static file. you can add the following to your nginx config file:

location /static/rest_framework/ {
alias /yourdjangoproject/lib/python2.7/site-packages/rest_framework/static/rest_framework/;}
0
votes

This problem is most likely something like using {{ STATIC_ROOT }} not {{ STATIC_URL }} in path, just like the links you refer to say.

0
votes

Did you run collectstatic ? If so, you don't have to alias DRF's static files.

Hope it helps.