Ich habe ein Modell Client
, wie annotieren i dann sortieren, die Max seiner zwei Felder:Wie der Max-Wert von zwei Feldern in einer Django QuerySet mit Anmerkungen versehen
from django.db import models
class Client(models.Model):
uploaded_photo_at = models.DateTimeField()
uploaded_document_at = models.DateTimeField()
Die folgenden:
Client.objects.annotate(
latest_activity_at=Max('uploaded_photo_at', 'uploaded_document_at', output_field=DateTimeField())
).order_by('latest_activity_at')
Löst diesen Fehler:
django.db.utils.ProgrammingError: function max(timestamp with time zone, timestamp with time zone) does not exist
LINE 1: ...oto_at", "clients_client"."uploaded_document_at", MAX("clien...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
ich verwende PosgreSQL und Django 1.11, ob das hilft.