Skip to content

Commit 8a034c6

Browse files
committed
Add new test for GenericForeignKey. Refs #230, #224
1 parent b99f53e commit 8a034c6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""
2+
Checks that Pylint does not complain about GenericForeignKey fields:
3+
https://github.com/PyCQA/pylint-django/issues/230
4+
"""
5+
# pylint: disable=missing-docstring
6+
7+
from django.db import models
8+
from django.contrib.contenttypes.models import ContentType
9+
from django.contrib.contenttypes.fields import GenericForeignKey
10+
11+
12+
class Ownership(models.Model):
13+
# for #230 the important bit is this FK field which doesn't
14+
# have any keyword arguments!
15+
owner_type = models.ForeignKey(ContentType, models.CASCADE)
16+
owner_id = models.PositiveIntegerField()
17+
owner = GenericForeignKey("owner_type", "owner_id")

0 commit comments

Comments
 (0)