I have the following model in my Django application; I want to get a queryset of my model with only one row for every unique value of a field (I do not care which row that would be at this point).
The problem is I cannot use the distinct
function, because I am using annotations in my query.
Any idea how this could be achieved?
My model
class Slot(models.Model):
# some other fields here
start = models.DateTimeField()
Notes
- This is basically the Django version of this StackOverflow question: SQLAlchemy: Selecting one row for each distinct value of a column