0

I cannot get my swagger to display properly on ubuntu django setup. And I am using function based API just like here https://github.com/m-haziq/django-rest-swagger-docs

This is the outcome which doesnt display swagger properly - ubuntu 16.04 (in AWS)

https://i.stack.imgur.com/aHKFJ.jpg <-- this is the problem, how to fix this ?

But on my development environment mac pc

https://i.stack.imgur.com/dAZno.jpg <--- its good on PC (Mac)

Here is my swagger schema. As you can see I have some logging:

https://gitlab.com/firdausmah/railerdotcom/blob/master/railercomapp/swagger_schema.py

Here are some logging:

2017-11-30 06:06:57,367 DEBUG xxxx home hello
2017-11-30 06:07:25,131 DEBUG get(self, request)
2017-11-30 06:07:25,132 DEBUG Check and load if the function has __doc__
2017-11-30 06:07:25,132 DEBUG swagger try yaml_doc
2017-11-30 06:07:25,134 DEBUG if yaml_doc

My Django/NGINX/Ubuntu setup is based on this:

https://jee-appy.blogspot.my/2017/01/deply-django-with-nginx.html

Feel free to look through my code,

https://gitlab.com/firdausmah/railerdotcom/tree/master

what could be the problem with swagger? On development its working. There is nothing different how I setup development & production. On production its using nginx, gunicorn, supervisor. on PC its running on python manage.py runserver.

Axil
  • 3,606
  • 10
  • 62
  • 136

1 Answers1

0

This error is because your swagger static files are inaccessible or at unknown location. You can see the error shown in your (http://railer.com/swagger/) console, which is:
enter image description here

To fix error try adding following lines to your settings.py:

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, "static"),
)

If this doesnt work then add your static files directory to it. For more info about it, look at this answer:

How to use a remote static file server while developing with django manage.py runserver

Haziq
  • 2,048
  • 1
  • 16
  • 27
  • thats for pointed out static files. i got it working by collectstatic and reconfiguring nginx to point to the static location. tqvm – Axil Nov 30 '17 at 23:41