Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: django/django
...
head fork: loic/django
compare: ticket22221
Checking mergeability… Don't worry, you can still create the pull request.
  • 1 commit
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 06, 2014
@loic loic Test case for #22221. 3179793
Showing with 10 additions and 1 deletion.
  1. +1 −0  tests/m2m_through/models.py
  2. +9 −1 tests/m2m_through/tests.py
View
1  tests/m2m_through/models.py
@@ -77,6 +77,7 @@ class Friendship(models.Model):
first = models.ForeignKey(PersonSelfRefM2M, related_name="rel_from_set")
second = models.ForeignKey(PersonSelfRefM2M, related_name="rel_to_set")
date_friended = models.DateTimeField()
+ reason = models.CharField(max_length=50)
# Custom through link fields
View
10 tests/m2m_through/tests.py
@@ -236,7 +236,7 @@ def test_self_referential_tests(self):
)
chris = PersonSelfRefM2M.objects.create(name="Chris")
- Friendship.objects.create(first=tony, second=chris, date_friended=datetime.now())
+ Friendship.objects.create(first=tony, second=chris, date_friended=datetime.now(), reason='because')
# Tony should now show that Chris is his friend.
self.assertQuerysetEqual(
@@ -245,6 +245,14 @@ def test_self_referential_tests(self):
],
attrgetter("name")
)
+
+ self.assertQuerysetEqual(
+ tony.friends.filter(rel_from_set__reason='because'), [
+ 'Chris'
+ ],
+ attrgetter("name")
+ )
+
# But we haven't established that Chris is Tony's Friend.
self.assertQuerysetEqual(
chris.friends.all(),

No commit comments for this range

Something went wrong with that request. Please try again.