title: Nested ModelSerializer
body: <p>I am trying to provide a nested json file through Django Rest Framework. I have been reading up on different way to nest my serializers but I am not getting it to work.</p>
  
  <p>I don't know how to create a modelserializer by myself, instead of directly pulling the data from my model...</p>
  
  <p>My error: </p>
  
  <blockquote>
    <p>AttributeError at /listings.json Got AttributeError when attempting to
    get a value for field <code>coordinates</code> on serializer <code>TestSerializer</code>.
    The serializer field might be named incorrectly and not match any
    attribute or key on the <code>Test</code> instance. Original exception text was:
    'Test' object has no attribute 'coordinates'.</p>
  </blockquote>
  
  <p>My serializer code:</p>
  
  <pre><code>from rest_framework import serializers
  from rentlistings.models import Test
  
  
  class coordinatesSerializer(serializers.ModelSerializer):
      class Meta:
          model = Test
          fields = ('latitude', 'longitude')
  
  
  class propertiesSerializer(serializers.ModelSerializer):
      class Meta:
          model = Test
          fields = ('price', 'price', 'yields',
                    'num_floor', 'num_rooms', 'elevator', 'garage',
                    'balcony_size', 'garden_area', 'parking', 'terass',
                    'loggia', 'cellar', 'hash_id')
  
  
  class TestSerializer(serializers.Serializer):
  coordinates = coordinatesSerializer(many=True, read_only=True)
  properties = propertiesSerializer(many=True, read_only=True)
  
      class Meta:
          model = Test
          fields = ('coordinates', 'properties')
  </code></pre>
  
  <p>My views.py</p>
  
  <pre><code>from rentlistings.models import Test
  from rentlistings.serializers import TestSerializer
  from rest_framework import generics
  # Create your views here.
  
  
  class test_list(generics.ListCreateAPIView):
          queryset = Test.objects.all()
          serializer_class = TestSerializer´
  </code></pre>
  
  <p>After correcting with @aircraft comments, I don't get an error but nothing is included in the API json:</p>
  
  <p><a href="https://i.stack.imgur.com/Cm1WG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cm1WG.jpg" alt="enter image description here"></a></p>
  
  <p>models.py</p>
  
  <pre><code>from django.db import models
  
  
  # Create your models here.
  class Test(models.Model):
      latitude = models.FloatField(blank=True, null=True)
      longitude = models.FloatField(blank=True, null=True)
      hash_id = models.BigIntegerField(primary_key=True, blank=True)
      price = models.BigIntegerField(blank=True, null=True)
      floor = models.TextField(blank=True, null=True)
      garden_area = models.FloatField(blank=True, null=True)
      parking = models.TextField(blank=True, null=True)
      terass = models.TextField(blank=True, null=True)
      loggia = models.TextField(blank=True, null=True)
      cellar = models.TextField(blank=True, null=True)
      elevator = models.NullBooleanField()
      garage = models.TextField(blank=True, null=True)
      balcony_size = models.TextField(blank=True, null=True)
      date = models.DateTimeField(blank=True, null=True)
      last_seen = models.DateTimeField(blank=True, null=True)
      num_floor = models.BigIntegerField(blank=True, null=True)
      num_rooms = models.BigIntegerField(blank=True, null=True)
      yields = models.FloatField(blank=True, null=True)
  
  
      class Meta:
          managed = False
          db_table = 'test'
  </code></pre>