1 | diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py
|
---|
2 | index 46f705f..5d75682 100644
|
---|
3 | --- a/django/utils/datastructures.py
|
---|
4 | +++ b/django/utils/datastructures.py
|
---|
5 | @@ -331,8 +331,7 @@ def setlistdefault(self, key, default_list=()):
|
---|
6 |
|
---|
7 | def appendlist(self, key, value):
|
---|
8 | """Appends an item to the internal list associated with key."""
|
---|
9 | - self.setlistdefault(key, [])
|
---|
10 | - super(MultiValueDict, self).__setitem__(key, self.getlist(key) + [value])
|
---|
11 | + super(MultiValueDict, self).setdefault(key, []).append(value)
|
---|
12 |
|
---|
13 | def items(self):
|
---|
14 | """
|
---|
15 | diff --git a/tests/regressiontests/utils/datastructures.py b/tests/regressiontests/utils/datastructures.py
|
---|
16 | index aaac9ba..d6db991 100644
|
---|
17 | --- a/tests/regressiontests/utils/datastructures.py
|
---|
18 | +++ b/tests/regressiontests/utils/datastructures.py
|
---|
19 | @@ -206,6 +206,12 @@ def test_multivaluedict(self):
|
---|
20 | self.assertEqual(list(d.itervalues()),
|
---|
21 | ['Developer', 'Simon', 'Willison'])
|
---|
22 |
|
---|
23 | + def test_appendlist(self):
|
---|
24 | + d = MultiValueDict()
|
---|
25 | + d.appendlist('name', 'Adrian')
|
---|
26 | + d.appendlist('name', 'Simon')
|
---|
27 | + self.assertEqual(d.getlist('name'), ['Adrian', 'Simon'])
|
---|
28 | +
|
---|
29 | def test_copy(self):
|
---|
30 | for copy_func in [copy.copy, lambda d: d.copy()]:
|
---|
31 | d1 = MultiValueDict({
|
---|