Skip to content

Commit

Permalink
make sure all ListModelMixin views considered as list view
Browse files Browse the repository at this point in the history
  • Loading branch information
DimasInchidi committed Mar 3, 2019
1 parent 75a5d86 commit 351a11c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/drf_yasg/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.db import models
from django.utils.encoding import force_text
from rest_framework import serializers, status
from rest_framework.mixins import DestroyModelMixin, RetrieveModelMixin, UpdateModelMixin
from rest_framework.mixins import DestroyModelMixin, RetrieveModelMixin, UpdateModelMixin, ListModelMixin
from rest_framework.request import is_form_media_type
from rest_framework.settings import api_settings as rest_framework_settings
from rest_framework.utils import encoders, json
Expand Down Expand Up @@ -225,6 +225,10 @@ def is_list_view(path, method, view):
# a detail action is surely not a list route
return False

# for GenericAPIView, if it's a list view then it should be a list view
if isinstance(view, ListModelMixin):
return True

# for GenericAPIView, if it's a detail view it can't also be a list view
if isinstance(view, (RetrieveModelMixin, UpdateModelMixin, DestroyModelMixin)):
return False
Expand Down

0 comments on commit 351a11c

Please sign in to comment.