title: Django Rest Framework Pagination How to fix ( name 'pagination' is not defined )
body: <p>I'm trying to paginate a search Query. All imports seem to be in the right place, but it keeps telling me that error. "pagination.PaginationSerializer is not defined".  I don't understand why? since I imported it "from rest_framework.pagination import PaginationSerializer". It's strange, I'm sure I'm doing something that is not being done in a proper way.So here is my code.</p>
  
  <p><strong>Note:</strong> I'm basing my code on the example on the official documentation. 
  <a href="http://www.django-rest-framework.org/api-guide/pagination#paginating-basic-data" rel="nofollow">http://www.django-rest-framework.org/api-guide/pagination#paginating-basic-data</a></p>
  
  <p>Here is my TraceBack from Browser:
  <a href="http://dpaste.com/2R1F03X/" rel="nofollow">http://dpaste.com/2R1F03X/</a> </p>
  
  <p>Exception Type: NameError at /user-search/</p>
  
  <p>Exception Value: name 'pagination' is not defined
  Exception Location:     /var/www/api/serializers.py in , line 19</p>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>from rest_framework import status
  from rest_framework.decorators import api_view
  from rest_framework.response import Response
  from django.core.paginator import Paginator , EmptyPage, PageNotAnInteger
  from django.shortcuts import HttpResponseRedirect
  import json
  
  from api.models import users, subjects
  from api.serializers import PaginatedUserSerializer, UserKarmaSerializer
  
  
  @api_view(['GET'])
  def user_search(request):
  
      """
      Url must be example (/?subject=iOS Development)
      """
  
      if request.method == 'GET':
  
          search_subject = request.QUERY_PARAMS.get('subject')
  
          # Query
          user_ids = subjects.objects.filter(
              ss__icontains=search_subject).values('id_user')
          user = users.objects.filter(pk__in=user_ids).order_by('-karma', 'rate')
  
          # Pagination Below
  
          paginator = Paginator(user, 20)
          page = request.QUERY_PARAMS.get('page')
  
          try:
              user = Paginator.page(page)
  
          except PageNotAnInteger:
              user = Paginator.page(1)
  
          except EmptyPage:
              user = Paginator.page(Paginator.num_pages)
  
          serializer_context = {'request': request}
          serializer = PaginatedUserSerializer(user,context=serializer_context)
  
          return Response(serializer.data, status=status.HTTP_200_OK)
  </code></pre>
  
  <p><strong>serializers.py</strong></p>
  
  <pre><code>from rest_framework import serializers
  from rest_framework.pagination import PaginationSerializer
  from api.models import users, chat, call, subjects
  
  
  
  """ Search Tutors Based on Rate &amp; Subjects """
  # Below is line 19
  class UserSearchSerializer(serializers.HyperlinkedModelSerializer):
  
      subjects = serializers.Field(source='user_subjects')
      user_rate = serializers.Field(source='rate_format')
  
      class Meta:
          model = users
          fields = ('name', 'nick', 'avatar_s', 'user_rate', 'id', 'subjects', 'bio', 'experience')
  
  
  class PaginatedUserSerializer(pagination.PaginationSerializer):
  
      class Meta:
          object_serializer_class = UserSearchSerializer
  </code></pre>