diff options
| author | Kaustubh <55352418+kc611@users.noreply.github.com> | 2020-08-22 11:23:50 +0530 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-08-26 09:43:39 +0200 |
| commit | b9be11d44265308863e4e8cfb458cd3605091452 (patch) | |
| tree | cf3ad9584a62bcd031c83b333fdd6bba0905b266 /django | |
| parent | 547a07fa7ec4364ea9ecd2aabfdd16ee4c63003c (diff) | |
Fixed #31918 -- Allowed QuerySet.in_bulk() to fetch on a single distinct field.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/query.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py index bce48e17ef..b39a988ab0 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -699,7 +699,8 @@ class QuerySet: if ( field_name != 'pk' and not opts.get_field(field_name).unique and - field_name not in unique_fields + field_name not in unique_fields and + not self.query.distinct_fields == (field_name,) ): raise ValueError("in_bulk()'s field_name must be a unique field but %r isn't." % field_name) if id_list is not None: |
