diff --git a/tests/regressiontests/transactions_regress/models.py b/tests/regressiontests/transactions_regress/models.py
index 54e6f4f..e8bca8a 100644
--- a/tests/regressiontests/transactions_regress/models.py
+++ b/tests/regressiontests/transactions_regress/models.py
@@ -2,3 +2,9 @@ from django.db import models
 
 class Mod(models.Model):
     fld = models.IntegerField()
+
+class M2mA(models.Model):
+    others = models.ManyToManyField('M2mB')
+
+class M2mB(models.Model):
+    fld = models.IntegerField()
diff --git a/tests/regressiontests/transactions_regress/tests.py b/tests/regressiontests/transactions_regress/tests.py
index 26ef416..2195fae 100644
--- a/tests/regressiontests/transactions_regress/tests.py
+++ b/tests/regressiontests/transactions_regress/tests.py
@@ -5,7 +5,7 @@ from django.db import connection, transaction
 from django.db.transaction import commit_on_success, commit_manually, TransactionManagementError
 from django.test import TransactionTestCase, skipUnlessDBFeature
 
-from .models import Mod
+from .models import Mod, M2mA, M2mB
 
 
 class TestTransactionClosing(TransactionTestCase):
@@ -164,3 +164,12 @@ class TestTransactionClosing(TransactionTestCase):
             _ = User.objects.all()[0]
         except:
             self.fail("A transaction consisting of a failed operation was not closed.")
+
+class TestManyToManyAddTransaction(TransactionTestCase):
+    def test_manyrelated_add_commit(self):
+        """test for 16818"""
+        a = M2mA.objects.create()
+        b = M2mB.objects.create(fld=10)
+        a.others.add(b)
+        transaction.rollback()
+        self.assertQuerysetEqual(a.others.all(),['<M2mB: M2mB object>'])
