I have a `Conversation` model, and a `Message` model. `Message` has a datefield `date_creation`.

`Conversation` has a manytomany `Message` through `messages` like this:

```
class Message(models.Model):
    date_last_modif = models.DateTimeField(auto_now=True)
    src = models.ForeignKey('User', related_name='message_src')
    dst = models.ForeignKey('User', related_name='message_dst')
    is_read = models.BooleanField(default=False)
    message = models.TextField(null=True, blank=True)

class Conversation(models.Model):
    messages = models.ManyToManyField(Message, related_name='conversations')

```

What I'd like to do is get all the conversations *that have no read message*, ordered by the most recent message first.

So here's my first filter which gets all the conversations that have a message not read yet:

```
p = current_user  # code omitted for sake of clarity
convs_not_read = Conversation.objects.filter(
    Q(messages__dst=p, messages__is_read=False)).distinct()

```

Note that I need distinct to get only conversations ids **once**, otherwise, if there are more than one un-read messages, you'll get as many times the same id as there are un-read messages in this conversation.

From now, I'm trying to have all conversations that have "no" un-read messages, and order them by *the most recent message*.

I've began with:

```
convs_read = Conversation.objects
        .filter(messages__dst=p)
        .exclude(pk__in=convs_not_read.values_list('id', flat=True))
        .distinct()

```

This works but they are not filtered by *the most recent message*. I'm stuck here. How would you do?

If I try: to add `.order_by('-messages__date_last_modif')` anywhere in this query, it has no effect, here:

```
        .filter(messages__dst=p)
        .order_by('-messages__date_last_modif')
        .exclude(pk__in=convs_not_read.values_list('id', flat=True))
        .distinct()

```

... or here:

```
        .filter(messages__dst=p)
        .exclude(pk__in=convs_not_read.values_list('id', flat=True))
        .distinct()
        .order_by('-messages__date_last_modif')

```

... doesn't change the result