diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index bf664c6..372579d 100644
a
|
b
|
class BaseQuery(object):
|
386 | 386 | # other than MySQL), then any fields mentioned in the |
387 | 387 | # ordering clause needs to be in the group by clause. |
388 | 388 | if not self.connection.features.allows_group_by_pk: |
389 | | grouping.extend([col for col in ordering_group_by |
| 389 | grouping.extend([str(col) for col in ordering_group_by |
390 | 390 | if col not in grouping]) |
391 | 391 | else: |
392 | 392 | ordering = self.connection.ops.force_no_ordering() |
diff --git a/tests/regressiontests/aggregation_regress/models.py b/tests/regressiontests/aggregation_regress/models.py
index fc2c44b..61a8dd3 100644
a
|
b
|
FieldError: Cannot resolve keyword 'foo' into field. Choices are: authors, conta
|
206 | 206 | >>> books.all() |
207 | 207 | [<Book: Artificial Intelligence: A Modern Approach>, <Book: Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp>, <Book: Practical Django Projects>, <Book: Python Web Development with Django>, <Book: Sams Teach Yourself Django in 24 Hours>, <Book: The Definitive Guide to Django: Web Development Done Right>] |
208 | 208 | |
| 209 | >>> Book.objects.annotate(num_authors=Count('authors')).filter(num_authors=2).dates('pubdate', 'day') |
| 210 | [datetime.datetime(1995, 1, 15, 0, 0), datetime.datetime(2007, 12, 6, 0, 0)] |
| 211 | |
209 | 212 | """ |
210 | 213 | } |
211 | 214 | |