Chat with Angular and Django./ Backend. Users list. Media.

Make a new serializer UserProfileSerializer in account/serializers/profile.py

Create a new UserListView class in the account/views/user_list.py

Add a new routing in account/urls.py.

admin

Define a custom pager class in backend/paginator.py.

Include the CustomPagination in the settings.py.

from rest_framework import serializers
from account.models import UserProfile

class UserProfileSerializer(serializers.ModelSerializer):

    class Meta:
        model = UserProfile
        fields = [
            'id',
            'username',
            'gender',
            'birthday',
        ]
from rest_framework.response import Response
from rest_framework.permissions import IsAuthenticated, AllowAny
from rest_framework import generics
from account.models import UserProfile
from account.serializers.profile import UserProfileSerializer

class UserListView(generics.ListAPIView):
    '''

    List of users.

    ______________

    '''
    queryset = UserProfile.objects.all().order_by('-id')
    serializer_class = UserProfileSerializer
    permission_classes = (AllowAny,)
admin
Потратить 2 кредита и начать обучение! У вас кредитов(а)
Задать вопрос, прокомментировать.