Open
Description
I seems to me, that v2.2.3 -> v2.2.4 introduces a bug: Adding a new entry to a existing object will add it not always as a new last entry... Sometimes it will be added as the second one.
I found this bug, because a integration tests failed. It looks like:
#...
response = self.client.post(
path='/admin/foo/add/',
data=get_test_form_data(
title='A Test Entry',
**{
'chapters-TOTAL_FORMS': '1',
'chapters-0-title': 'Chapter One',
'chapters-0-position': '0',
},
),
)
test_item = Foo.objects.get()
self.assertEqual(test_item.title, 'A Test Entry')
#...
response = self.client.post(
path=f'/admin/foo/{test_item.pk}/change/',
data=get_test_form_data(
title='A Test Entry',
**{
'chapters-TOTAL_FORMS': '2',
'chapters-INITIAL_FORMS': '1',
'chapters-0-id': str(chapter1.pk),
'chapters-0-test': str(test_item.pk),
'chapters-0-title': 'Chapter One',
'chapters-0-position': '1',
'chapters-1-test': str(test_item.pk),
'chapters-1-title': 'Chapter Two',
'chapters-1-position': '0',
'chapters-__prefix__-test': str(test_item.pk),
'chapters-__prefix__-position': '0',
},
),
)
test_item.refresh_from_db()
self.assertEqual(
list(test_item.chapters.values_list('title', flat=True)), ['Chapter One', 'Chapter Two']
)
#...
With v2.2.3 it's correct: ['Chapter One', 'Chapter Two']
With v2.2.4 it's: ['Chapter Two', 'Chapter One']
Metadata
Metadata
Assignees
Labels
No labels