title: Serialize foreign key object that is AbstractUser
body: <p>I am serializing a model using the Django REST framework successfully, but would like to add a field from a related model. I have seen other posts describe how to do this using nested serializers, however mine is different because the other model I am trying to access is an <code>AbstractUser</code> class.
  I would like to serialize the <code>UserDefinedEquipName</code> field from CustomUser.</p>
  
  <p>models (some fields removed for clarity):</p>
  
  <p>accounts/models.py</p>
  
  <pre><code>from django.contrib.auth.models import AbstractUser
  
  class CustomUser(AbstractUser): 
      UserDefinedEquipName = models.CharField(max_length=50, default = "Default equip",)
      ....
  </code></pre>
  
  <p>builds/models.py</p>
  
  <pre><code>from accounts.models import CustomUser
  from django.contrib.auth import get_user_model
  
  class Build(models.Model):
      author =  models.ForeignKey(get_user_model(),on_delete=models.CASCADE,)
      machineName = models.OneToOneField(max_length=50,blank=True,)
      ....
  </code></pre>
  
  <p>So my thought is to pass the value into the serializer but can't seem to figure out how to access the value without getting error <code>AttributeError: type object 'Build' has no attribute 'CustomUser'</code></p>
  
  <p>I have tried:
  My serializers.py:</p>
  
  <pre><code>from rest_framework import serializers
  from .models import Data, Build, CustomUser
  from django.contrib.auth.models import AbstractUser
  
  class buildStatsAPI_serializer(serializers.ModelSerializer):
      equipName = Build.CustomUser.UserDefinedEquipName
      #also tried:
      #equipName = Build.CustomUser__set.all()
  
      class Meta:
          fields = ('id','author','machineName','equipName',)
      model = Build
  </code></pre>
  
  <p>Am I missing something small here? Or is there a much better way of doing this. It seems like if this wasn't an AbstractUser class it would be much easier.</p>
  
  <p>EDIT - Added views.py</p>
  
  <pre><code>class buildStatsAPI(generics.ListCreateAPIView):#for build stats JSON
      permission_classes = (permissions.IsAuthenticated,)
      serializer_class = buildStatsAPI_serializer
      def get_queryset(self):
          machinesOwned =CustomUser.objects.filter(customerTag=self.request.user.customerTag).filter(isDevice=True)
          machineList = []
          for machine in machinesOwned:
              machineList = machineList + [machine.id]
          query = Build.objects.filter(deleted=0, author_id__in=machineList,).values().order_by('pk')
          return query
  </code></pre>