Skip to content

replace DRF @list_route and @detail_route with @action #659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion example/api/resources/identity.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
from django.contrib.auth import models as auth_models
from django.utils import encoding
from rest_framework import generics, parsers, renderers, serializers, viewsets
from rest_framework.decorators import detail_route, list_route
from rest_framework.response import Response

from rest_framework_json_api import mixins, utils

from ..serializers.identity import IdentitySerializer
from ..serializers.post import PostSerializer

try:
from rest_framework.decorators import action

def detail_route(**kwargs):
return action(detail=True, **kwargs)

def list_route(**kwargs):
return action(detail=False, **kwargs)

except ImportError:
from rest_framework.decorators import detail_route, list_route


class Identity(mixins.MultipleIDMixin, viewsets.ModelViewSet):
queryset = auth_models.User.objects.all().order_by('pk')
Expand Down