Changes between Initial Version and Version 1 of Ticket #36352


Ignore:
Timestamp:
Apr 25, 2025, 7:46:22 AM (4 months ago)
Author:
Joseph Yu
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #36352 – Description

    initial v1  
    2626django.core.exceptions.FieldError: Cannot select the 'created' alias. Use annotate() to promote it.
    2727}}}
     28
     29Current workaround is to include the annotated field in .values like so
     30
     31{{{
     32>>> c = b.filter(id=OuterRef('id')).values('schema', 'created')
     33>>> d = Tenant.objects.values('schema_name').annotate(created_at=Subquery(c.values('created')[:1]))
     34>>> d[:1]
     35<QuerySet [{'schema_name': 'sample', 'created_at': datetime.date(2024, 11, 4)}]>
     36}}}
Back to Top