diff --git a/src/modelsubquery/functions.py b/src/modelsubquery/functions.py index 1c8dbde..9051d13 100644 --- a/src/modelsubquery/functions.py +++ b/src/modelsubquery/functions.py @@ -13,7 +13,7 @@ def _model_fields(model, fields): then return all the declared fields. """ # TODO: the pk/id field should always be returned - declared = {f.column for f in model._meta.get_fields()} + declared = {f.column for f in model._meta.get_fields() if f.concrete} if fields is None: return declared diff --git a/testproject/testapp/models.py b/testproject/testapp/models.py index 0760033..6e29f72 100644 --- a/testproject/testapp/models.py +++ b/testproject/testapp/models.py @@ -31,3 +31,8 @@ class Person(models.Model): birth = models.DateField(default=date.today) objects = PersonQuerySet.as_manager() + + +class Shelve(models.Model): + title = models.CharField(max_length=100) + books = models.ManyToManyField("Book", related_name="shelves")