I'm learning django, I am trying to order my objects by field last_name
but I think I might be missing something, this is how my function looks:
def list(self, *args, **kwargs):
data = super().list(*args, **kwargs)
data = data.data
x = self.queryset.order_by('last_name')
print(x) # I'm priting X but I still get list not ordered by last_name
return Response(data)
UPdate
I think what I must do is affect the variable ordering in my Model meta class but I need it to order by lowercase:
class Meta(DRYPermissionModel.Meta):
ordering = ['username'] # ORDER BY user_name but as if the string was lower case