title: How to get field name instead of foreign id in django
body: <p>In my django app, i have four model tables linked using foreign keys, the problem is, when i make a query for any model table, the fields that are linked through foreign keys are returned as id's instead of the name.</p>
  <p>My way does not work.</p>
  <p>My <strong>customers models.py</strong> file</p>
  <p><em>1st model</em></p>
  <pre><code>class Customer(models.Model):
      name = models.CharField(max_length=50)
      phone = models.CharField(max_length=20, unique=True)
      email = models.EmailField(max_length=255, unique=True, blank=True)
      image = models.ImageField(default='default.png', upload_to='customer_photos/%Y/%m/%d/')
      data_added = models.DateField(default=datetime.now, blank=True)
  
      def __str__(self):
          return self.name
  </code></pre>
  <p><em>2nd model</em></p>
  <pre><code>class ShippingAddress(models.Model):
      customer = models.ForeignKey(Customer, on_delete=models.CASCADE, related_name=&quot;customer_ship_address&quot;)
      description = models.TextField(blank=True)   
      frequent_customer = models.BooleanField(default=False)
      address = models.CharField(max_length=50, blank=True)
      zip_code = models.CharField(max_length=12, blank=True)
      location = models.CharField(max_length=255)
  
      def __str__(self):
          return self.customer.name
  </code></pre>
  <p><em>3rd model - PaymentInvoice</em></p>
  <pre><code>class paymentInvoice(models.Model):
  
      shipping_address_owner = models.ForeignKey(
          ShippingAddress, on_delete=models.CASCADE, related_name=&quot;customer_invoice&quot;)
      product = models.ManyToManyField(
          Product, related_name='product_invoice')
      mode = models.CharField(max_length=20, choices=paymentMode.choices, default=paymentMode.MPESA)
      date = models.DateField(default=datetime.now)
      invoice_id = models.CharField(
          max_length=50, unique=True, default=increment_invoice_number)
      quantity = models.PositiveSmallIntegerField()
      status = models.CharField(
          max_length=20, choices=paymentStatus.choices, default=paymentStatus.PENDING)
      payment_made = models.DecimalField(max_digits=20, decimal_places=2)
  
      def __str__(self):
          return self.shipping_address_owner.customer.name
  </code></pre>
  <p>My <strong>Products models.py</strong> file</p>
  <pre><code>class Product(models.Model):
      slug = models.CharField(max_length=200, unique=True)
      name = models.CharField(max_length=200)
      available = models.BooleanField(default=True)
      description = models.TextField(blank=True)
      image = models.ImageField(default='default_product.jpg', upload_to='product_photos')
      category = models.CharField(max_length=200)
      qty_amount = models.CharField(
          max_length=20, choices=Qty_Choices, default='250ml')
      price = models.DecimalField(max_digits=10, decimal_places=2)
  
      def __str__(self):
          return self.name
  </code></pre>
  <p>My <strong>PaymentInvoice views.py</strong> file</p>
  <pre><code>class paymentInvoiceListCreateView(ListCreateAPIView):
      &quot;&quot;&quot;
      ListCreateAPIView executes both 'GET' and 'POST' requests. i.e listing a queryset or creating a model instance.
      &quot;&quot;&quot;
      serializer_class = paymentInvoiceSerializer
      queryset = paymentInvoice.objects.all().order_by(
          '-date').values(shipping_address_owner__customer)
  </code></pre>
  <p>When i make the above query the api returns the following, where the <em>product</em> field and <em>shipping_address_owner</em> field are just id's. I need there respective names instead.</p>
  <pre><code>{
      &quot;count&quot;: 6,
      &quot;next&quot;: null,
      &quot;previous&quot;: null,
      &quot;results&quot;: [
          {
              &quot;id&quot;: 9,
              &quot;mode&quot;: &quot;Mpesa&quot;,
              &quot;date&quot;: &quot;2020-07-27&quot;,
              &quot;invoice_id&quot;: &quot;INV-0006&quot;,
              &quot;quantity&quot;: 1,
              &quot;status&quot;: &quot;Pending&quot;,
              &quot;payment_made&quot;: &quot;500.00&quot;,
              &quot;shipping_address_owner&quot;: 9,
              &quot;product&quot;: [
                  1
              ]
          },
  </code></pre>
  <p>EDIT: <strong>paymentInvoiceSerializer</strong></p>
  <pre><code>class paymentInvoiceSerializer(serializers.ModelSerializer):
      class Meta:
          model = paymentInvoice
          fields = '__all__'
  </code></pre>