Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add ordering

akjanik9b4aae8bbb81
diff --git a/saleor/order/migrations/0030_ordernote_is_public.py b/saleor/order/migrations/0030_auto_20180117_0835.py
similarity index 53%
rename from saleor/order/migrations/0030_ordernote_is_public.py
rename to saleor/order/migrations/0030_auto_20180117_0835.py
index 32f013e873..02161ac575 100644
--- a/saleor/order/migrations/0030_ordernote_is_public.py
+++ b/saleor/order/migrations/0030_auto_20180117_0835.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Generated by Django 1.11.5 on 2018-01-16 11:11
+# Generated by Django 1.11.5 on 2018-01-17 14:35
from __future__ import unicode_literals
from django.db import migrations, models
@@ -12,9 +12,18 @@ class Migration(migrations.Migration):
]
operations = [
+ migrations.AlterModelOptions(
+ name='ordernote',
+ options={'ordering': ('date',)},
+ ),
migrations.AddField(
model_name='ordernote',
name='is_public',
field=models.BooleanField(default=True),
),
+ migrations.AlterField(
+ model_name='ordernote',
+ name='date',
+ field=models.DateTimeField(auto_now_add=True, db_index=True),
+ ),
]
diff --git a/saleor/order/models.py b/saleor/order/models.py
index 70501c7cfd..c676385c2a 100644
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -362,12 +362,15 @@ class OrderNote(models.Model):
user = models.ForeignKey(
settings.AUTH_USER_MODEL, blank=True, null=True,
on_delete=models.SET_NULL)
- date = models.DateTimeField(auto_now_add=True)
+ date = models.DateTimeField(db_index=True, auto_now_add=True)
order = models.ForeignKey(
Order, related_name='notes', on_delete=models.CASCADE)
content = models.CharField(max_length=250)
is_public = models.BooleanField(default=True)
+ class Meta:
+ ordering = ('date', )
+
def __str__(self):
return pgettext_lazy(
'Order note str',