From d2b8d641e28b89f4da88556acebcae8f5eaccdc5 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sun, 24 Jan 2021 16:46:25 +0100 Subject: [PATCH] Fix ordering of messages --- .../migrations/0005_auto_20210124_1644.py | 17 +++++++++++++++++ src/pictures/models.py | 3 +++ 2 files changed, 20 insertions(+) create mode 100644 src/pictures/migrations/0005_auto_20210124_1644.py diff --git a/src/pictures/migrations/0005_auto_20210124_1644.py b/src/pictures/migrations/0005_auto_20210124_1644.py new file mode 100644 index 0000000..96bc4e4 --- /dev/null +++ b/src/pictures/migrations/0005_auto_20210124_1644.py @@ -0,0 +1,17 @@ +# Generated by Django 3.1.5 on 2021-01-24 16:44 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("pictures", "0004_auto_20210124_1407"), + ] + + operations = [ + migrations.AlterModelOptions( + name="message", + options={"ordering": ["-received_at"]}, + ), + ] diff --git a/src/pictures/models.py b/src/pictures/models.py index ae5f1d6..6dc6676 100644 --- a/src/pictures/models.py +++ b/src/pictures/models.py @@ -28,6 +28,9 @@ class Message(models.Model): content = models.TextField(blank=True) received_at = models.DateTimeField(default=timezone.now) + class Meta: + ordering = ["-received_at"] + def __str__(self): truncator = Truncator(self.content) truncated_content = truncator.words(15)