plateforme-corres2math/apps/api/viewsets.py

18 lines
628 B
Python
Raw Normal View History

2020-09-20 20:31:37 +00:00
from django.contrib.auth.models import User
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.filters import SearchFilter
from rest_framework.viewsets import ModelViewSet
from .serializers import UserSerializer
class UserViewSet(ModelViewSet):
"""
Display list of users.
"""
2020-09-24 12:15:42 +00:00
queryset = User.objects.order_by("id").all()
2020-09-20 20:31:37 +00:00
serializer_class = UserSerializer
filter_backends = [DjangoFilterBackend, SearchFilter]
filterset_fields = ['id', 'first_name', 'last_name', 'email', 'is_superuser', 'is_staff', 'is_active', ]
search_fields = ['$first_name', '$last_name', ]