mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Added tests for m2m queries with custom pk on the end models
It seems this case was fixed somewhere between 1.5.x and 1.6.x. I added tests as I wasn't able to find any tests for these cases. Refs #21879
This commit is contained in:
@@ -27,7 +27,7 @@ from .models import (
|
||||
BaseA, FK1, Identifier, Program, Channel, Page, Paragraph, Chapter, Book,
|
||||
MyObject, Order, OrderItem, SharedConnection, Task, Staff, StaffUser,
|
||||
CategoryRelationship, Ticket21203Parent, Ticket21203Child, Person,
|
||||
Company, Employment)
|
||||
Company, Employment, CustomPk, CustomPkTag)
|
||||
|
||||
|
||||
class BaseQuerysetTest(TestCase):
|
||||
@@ -3243,3 +3243,16 @@ class ForeignKeyToBaseExcludeTests(TestCase):
|
||||
SpecialCategory.objects.filter(categoryitem__id=c1.pk),
|
||||
[sc1], lambda x: x
|
||||
)
|
||||
|
||||
|
||||
class ReverseM2MCustomPkTests(TestCase):
|
||||
def test_ticket_21879(self):
|
||||
cpt1 = CustomPkTag.objects.create(id='cpt1', tag='cpt1')
|
||||
cp1 = CustomPk.objects.create(name='cp1', extra='extra')
|
||||
cp1.custompktag_set.add(cpt1)
|
||||
self.assertQuerysetEqual(
|
||||
CustomPk.objects.filter(custompktag=cpt1), [cp1],
|
||||
lambda x: x)
|
||||
self.assertQuerysetEqual(
|
||||
CustomPkTag.objects.filter(custom_pk=cp1), [cpt1],
|
||||
lambda x: x)
|
||||
|
||||
Reference in New Issue
Block a user