i use model with Meta
ordering = ['-published_date']
Now in view:
class InvoiceViewSet(viewsets.ModelViewSet):
queryset = Invoice.objects.all()
serializer_class = InvoiceSerializer
filter_fields = ('table',)
And serializer:
class InvoiceSerializer(serializers.ModelSerializer):
items = ItemSerializer(many=True, allow_add_remove=True)
class Meta:
model = Invoice
fields = ('id', 'items', 'table', 'published_date')
But this ordering doesn't work, it shows me ordering ASC, and i need DESC, it doesn't affect order at all.
What am i doing wrong?
Invoice.objects.all()
from the shell does it show DESC ordering?get_queryset()
method but, ive done this before just like you and its worked for me. Somehting else must be wrong.