Fix ordering of messages
This commit is contained in:
parent
387b878045
commit
d2b8d641e2
2 changed files with 20 additions and 0 deletions
17
src/pictures/migrations/0005_auto_20210124_1644.py
Normal file
17
src/pictures/migrations/0005_auto_20210124_1644.py
Normal 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"]},
|
||||||
|
),
|
||||||
|
]
|
|
@ -28,6 +28,9 @@ class Message(models.Model):
|
||||||
content = models.TextField(blank=True)
|
content = models.TextField(blank=True)
|
||||||
received_at = models.DateTimeField(default=timezone.now)
|
received_at = models.DateTimeField(default=timezone.now)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
ordering = ["-received_at"]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
truncator = Truncator(self.content)
|
truncator = Truncator(self.content)
|
||||||
truncated_content = truncator.words(15)
|
truncated_content = truncator.words(15)
|
||||||
|
|
Loading…
Reference in a new issue