title: related objects queries django rest framework
body: <p>I have the following models </p>
  
  <pre><code>class STUser(AbstractBaseUser):
      email = models.EmailField(unique=True)
      name = models.CharField(max_length=255)
      companyname = models.CharField(max_length=200, blank=True, null=True)
      ...
  
  class VenuePermissions(models.Model):
      user = models.ForeignKey(STUser, on_delete=models.CASCADE)
      venue = models.ForeignKey(Venue, on_delete=models.CASCADE) 
      signupvaildatestring = models.CharField(max_length=200, blank=True, null=True)
      ...
  </code></pre>
  
  <p>I want to grab all the <code>STUser</code> objects and grab all their permissions. </p>
  
  <p>So what I would like is to grab all the <code>VenuePermissions</code> objects. And grab the <code>user</code> and <code>venue</code> object of each venuePermission</p>
  
  <p>Two ways I can do this. use the <code>VenuePermissions_set</code> attribute on <code>STUser</code> but then how do I grab the venue when its just going to be a <code>pk</code> value?</p>
  
  <p>Or focus on the <code>VenuePermissions</code> objects and grab the user and venue from the pk values but how? </p>
  
  <p>I remember nested queries, and I kinda did one in my browse code. </p>
  
  <p>here is an example: </p>
  
  <pre><code> rooms = Room.objects.filter(venue=OuterRef('pk'), sixtyroundseatingoption= True)
              venuelist = venuelist.annotate(sixtyrounds=Exists(rooms))
              venuelist = venuelist.filter(Q(sixtyrounds = True) | Q(fullbuyoutsixtyroundseatingoption = True))
  </code></pre>
  
  <p>I've done the set objects in a serializer before</p>
  
  <p>Example serializer: </p>
  
  <pre><code>class RoomAndImageSerializer(serializers.ModelSerializer):
      roomimage_set = RoomImageSerializer(many=True, read_only=True)
      class Meta:
          model = Room
          fields = ('pk','name')
  </code></pre>
  
  <p>any help with this query would be appreciated!</p>
  
  <p>So this is what I am currently trying, I will post an answer if this works: </p>
  
  <pre><code>class VenueUserList(ListAPIView):
      serializer_class = VenueUserListSerializer
      queryset = VenuePermissions.objects.select_related('user').select_related('venue').filter(signupvaildatestring=None)
  
  class VenueUserListSerializer(serializers.ModelSerializer):
      user = UserSerializer()
      venue = VenueSerializer()
      class Meta:
          model = VenuePermissions
          fields = ('user', 'venue', 'isvenueviewer', 'isvenueeventplanner', 'isvenueadministrator')
  </code></pre>