title: How to order Django queryset by an attribute of the parent model?
body: <p>I have a Profile model that extends the Django User model,</p>
  
  <pre><code>class Profile(models.Model):
      user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, null=False, blank=True)
      weight = models.DecimalField(max_digits=5, decimal_places=2, null=True, blank=True)
      height = models.DecimalField(max_digits=5, decimal_places=2, null=True, blank=True)
      activity_level = models.DecimalField(max_digits=2, decimal_places=1, null=True, blank=True)
      tdee = models.IntegerField(null=True, blank=True)
  
      def __str__(self):
          return self.get_username()
  </code></pre>
  
  <p>and when I try to access the queryset:</p>
  
  <pre><code>queryset = Profile.objects.all().order_by('-date_joined')
  </code></pre>
  
  <p>it says </p>
  
  <pre><code>FieldError at /users/
  Cannot resolve keyword 'date_joined' into field. Choices are: activity_level, height, id, set, sex, tdee, user, user_id, weight
  </code></pre>
  
  <p>How do I order my queryset by the attribute from the parent model of the Profile class, which in this case is the User model?</p>
  
  <p>Thanks in advance.</p>