Skip to content

Commit e28f598

Browse files
committed
raise NotSupportedError for QuerySet.prefetch_related()
1 parent f7dfa83 commit e28f598

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ Migrations for 'admin':
114114
- `datetimes()`
115115
- `distinct()`
116116
- `extra()`
117+
- `prefetch_related()`
117118

118119
- `Subquery`, `Exists`, and using a `QuerySet` in `QuerySet.annotate()` aren't
119120
supported.

django_mongodb/compiler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ def check_query(self):
101101
raise NotSupportedError("QuerySet.dates() is not supported on MongoDB.")
102102
raise NotSupportedError("QuerySet.distinct() is not supported on MongoDB.")
103103
if self.query.extra:
104+
if any(key.startswith("_prefetch_related_") for key in self.query.extra):
105+
raise NotSupportedError("QuerySet.prefetch_related() is not supported on MongoDB.")
104106
raise NotSupportedError("QuerySet.extra() is not supported on MongoDB.")
105107
if any(
106108
isinstance(a, Aggregate) and not isinstance(a, Count)

0 commit comments

Comments
 (0)