Why Nostr? What is Njump?
2024-08-21 22:32:39
in reply to

Trey Hunner 🐍 on Nostr: Since you don't want values but actual model objects instead, you may need to use a ...

Since you don't want values but actual model objects instead, you may need to use a subquery.

This maybe?

subquery = (
ContainerBase.objects
.filter(cname=OuterRef('cname'))
.values('cname')
.annotate(max_ctime=Max('ctime'))
.values('max_ctime')
)

query = (
ContainerBase.objects
.annotate(max_ctime=Subquery(subquery))
.filter(ctime=F('max_ctime'))
.order_by('cname')
.distinct('cname')
)
Author Public Key
npub106g4n7la25nyzhyd9h3wf3m9fcmxpzplnn9wwg98p73uru70razsjsuas2