Deterministic ordering for tags

This commit is contained in:
Karl Hobley 2015-08-03 20:27:22 +01:00
parent 1d0fa2a3bf
commit 5b123ca5f4
2 changed files with 2 additions and 2 deletions

View file

@ -56,7 +56,7 @@ class StreamField(Field):
class TagsField(Field):
def to_representation(self, value):
return list(value.all().values_list('name', flat=True))
return list(value.all().order_by('name').values_list('name', flat=True))
class BaseSerializer(serializers.ModelSerializer):

View file

@ -586,7 +586,7 @@ class TestPageDetail(TestCase):
self.assertEqual(content['date'], '2013-12-02')
# Check that the tags were serialised properly
self.assertEqual(content['tags'], ['wagtail', 'bird'])
self.assertEqual(content['tags'], ['bird', 'wagtail'])
# Check that the feed image was serialised properly
self.assertIsInstance(content['feed_image'], dict)