title: django rest framework hide specific fields in list display?
body: <blockquote>
    <p>I want to hide specific fields of a model on the list display at <strong><code>persons/</code></strong> and show all the fields on the detail display <strong><code>persons/jane</code></strong></p>
  </blockquote>
  
  <p>I am relatively new to the rest framework and the documentation feels like so hard to grasp.</p>
  
  <p>Here's what I am trying to accomplish.</p>
  
  <p>I have a simple <code>Person</code> model,</p>
  
  <pre><code># model
  class Person(models.Model):
      first_name = models.CharField(max_length=30, blank=True)
      last_name = models.CharField(max_length=30, blank=True)
      nickname = models.CharField(max_length=20)
      slug = models.SlugField()
      address = models.TextField(max_length=300, blank=True)
  </code></pre>
  
  <p>and the serializer class </p>
  
  <pre><code># serializers
  
  class PersonListSerializer(serializers.ModelSerializer):
      class Meta:
          model = Person
          fields = ('nickname', 'slug')
  
  
  class PersonSerializer(serializers.ModelSerializer):
      class Meta:
          model = Person
          fields = ('first_name', 'last_name', 'nickname', 'slug', 'address')
  </code></pre>
  
  <p>and the viewsets.</p>
  
  <pre><code># view sets (api.py)
  
  class PersonListViewSet(viewsets.ModelViewSet):
      queryset = Person.objects.all()
      serializer_class = PersonListSerializer
  
  
  class PersonViewSet(viewsets.ModelViewSet):
      queryset = Person.objects.all()
      serializer_class = PersonSerializer
  </code></pre>
  
  <p>at the url <strong><code>persons</code></strong> I want to dispaly list of persons, just with fields <code>nickname</code> and <code>slug</code> and at the url <strong><code>persons/[slug]</code></strong> I want to display all the fields of the model.</p>
  
  <p>my router configurations,</p>
  
  <pre><code>router = routers.DefaultRouter()
  router.register(r'persons', api.PersonListViewSet)
  router.register(r'persons/{slug}', api.PersonViewSet)
  </code></pre>
  
  <p>I guess the second configuration is wrong, How can I achieve what I am trying to do? </p>
  
  <p><strong>update:</strong></p>
  
  <p>the output to <strong><code>persons/slug</code></strong> is <code>{"detail":"Not found."}</code> but it works for <strong><code>person/pk</code></strong></p>
  
  <p>Thank you </p>