diff --git a/README.md b/README.md index 8e0c45f35..dbf2f1478 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,7 @@ Migrations for 'admin': - `datetimes()` - `distinct()` - `extra()` + - `prefetch_related()` - `Subquery`, `Exists`, and using a `QuerySet` in `QuerySet.annotate()` aren't supported. diff --git a/django_mongodb/compiler.py b/django_mongodb/compiler.py index d950c8d59..5d230d238 100644 --- a/django_mongodb/compiler.py +++ b/django_mongodb/compiler.py @@ -101,6 +101,8 @@ def check_query(self): raise NotSupportedError("QuerySet.dates() is not supported on MongoDB.") raise NotSupportedError("QuerySet.distinct() is not supported on MongoDB.") if self.query.extra: + if any(key.startswith("_prefetch_related_") for key in self.query.extra): + raise NotSupportedError("QuerySet.prefetch_related() is not supported on MongoDB.") raise NotSupportedError("QuerySet.extra() is not supported on MongoDB.") if any( isinstance(a, Aggregate) and not isinstance(a, Count)