diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index ee1966b76f..482c718118 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -75,7 +75,9 @@ class Media(StrAndUnicode):
def add_js(self, data):
if data:
- self._js.extend([path for path in data if path not in self._js])
+ for path in data:
+ if path not in self._js:
+ self._js.append(path)
def add_css(self, data):
if data:
diff --git a/tests/regressiontests/forms/media.py b/tests/regressiontests/forms/media.py
index fc1b412bcf..f47875db34 100644
--- a/tests/regressiontests/forms/media.py
+++ b/tests/regressiontests/forms/media.py
@@ -112,6 +112,18 @@ media_tests = r"""
+# Regression check for #12879: specifying the same JS file multiple
+# times in a single Media instance should result in that file only
+# being included once.
+>>> class MyWidget4(TextInput):
+... class Media:
+... js = ('/path/to/js1', '/path/to/js1')
+
+>>> w4 = MyWidget4()
+>>> print w4.media
+
+
+
###############################################################
# Property-based media definitions
###############################################################