Fix ordering of messages

This commit is contained in:
Gabriel Augendre 2021-01-24 16:46:25 +01:00
parent 387b878045
commit d2b8d641e2
2 changed files with 20 additions and 0 deletions

View file

@ -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"]},
),
]

View file

@ -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)