I'm trying to run Django REST Swagger on (https://docs.djangoproject.com/en/2.0/intro/tutorial01/) to make sure I understand how it works, before trying to integrate Django REST Swagger into my larger project.
What I've done: I took the code from the sample Django project and tried integrating Django REST Swagger.
In setting.py
I added rest_framework_swagger
under INSTALLED_APPS
. My stuff for static files is as follows:
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
os.path.join(BASE_DIR, 'polls/static'),
)
STATIC_ROOT = '/home/tengelbrecht/Documents/ENV/django-project'
STATIC_URL = '/static/'
In urls.py
, I have:
from django.conf.urls import include, url
from django.contrib import admin
from rest_framework_swagger.views import get_swagger_view
schema_view = get_swagger_view(title='Polls API')
urlpatterns = [
url(r'^$', schema_view),
url(r"^polls/", include("polls.urls")),
url(r"^admin/", admin.site.urls)
]
When I run the project on localhost (using python manage.py runserver
), The result is as in the attached screenshot. The relevant pieces are the localhost on the left screen, and the terminal on the far right.
Any help would be apreciated. Please comment if you need any more information. I feel that there is a simple fix for this, as in I missed one step of integrating Django REST Swagger into the project, but I currently can't figure it out after hours of Googling.
Django REST Swagger works with API's built using http://www.django-rest-framework.org/. As per my understanding, you are using plain Django. Once you covert your current API into DRF API. Swagger should list your API.