Missing bootstrap resources in Django-Rest-Framework

后端 未结 3 682
日久生厌
日久生厌 2020-12-17 17:41

I\'m using the new django-rest-framework 2.0 and have been following the tutorial for creating a rest based API. The API is now complete, however I am having trouble getting

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-17 18:17

    First up, I'm assuming that you mean the bootstrap static resources aren't loading for the browsable API? (Although I guess it could be that you're trying to use them elsewhere in your project?)

    If you're running with DEBUG=True they should be served automatically, but once you're running with DEBUG=False you need to make sure to run manage.py collectstatic and ensure your STATIC_ROOT and STATIC_URL settings are correct.

    Django's static files documentation should help: https://docs.djangoproject.com/en/dev/howto/static-files/

    If you're still not having any luck I'd suggest you double check your Django version (1.3 and upwards is supported), and REST framework version (Anything from version 2 onwards), and make sure you step through the tutorial step-by-step, taking care particularly with the project setup.

提交回复
热议问题