| 1 | from django.db import models
|
|---|
| 2 | from django.test.testcases import TestCase
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 | class MyModel(models.Model):
|
|---|
| 6 | group_id = models.PositiveIntegerField()
|
|---|
| 7 | user_id = models.PositiveIntegerField()
|
|---|
| 8 | other_id = models.PositiveIntegerField(null=True)
|
|---|
| 9 | other = models.ForeignObject(
|
|---|
| 10 | 'OtherModel',
|
|---|
| 11 | from_fields=('other_id', 'user_id', 'group_id'),
|
|---|
| 12 | to_fields=('id', 'user_id', 'group_id'),
|
|---|
| 13 | null=True
|
|---|
| 14 | )
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 | class OtherModel(models.Model):
|
|---|
| 18 | group_id = models.PositiveIntegerField()
|
|---|
| 19 | user_id = models.PositiveIntegerField()
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 | class BugTestCase(TestCase):
|
|---|
| 23 |
|
|---|
| 24 | def test_bug(self):
|
|---|
| 25 | OtherModel.objects.exclude(mymodel__id__in=[1,2,3])[0]
|
|---|