get_by_id should be aware of previous filters
kiddouk opened this issue · 0 comments
kiddouk commented
Considering this case :
class A(models.Model):
user = models.ReferenceField(B)
class B(models.Model):
att = models.Attribute()
b1 = B(att='test)
b1.save()
b2 = B(att='test')
b2.save()
a = A(user=b1)
a.save()
self.assertEqual(a.user_set.get_by_id(b1.id), b1)
self.assertEqual(a.user_set.get_by_id(b2.id), None)
The second test will fail as get_by_id
doesn't take into account any filter/zfilter/excludes.