Opened 7 years ago

Closed 7 years ago

#28419 closed New feature (duplicate)

Support for value() usage with PostgreSQL-specific JSONFields

Reported by: daishi Owned by: nobody
Component: contrib.postgres Version: 1.11
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


This is a feature request for the PostgreSQL-specific JSONField documented here:

Following from the example starting at:

It would be great if the extended field naming allowed the following to succeed:

>>> Dog.objects.values('data__breed')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/daishi/.virtualenvs/testdjango/lib/python2.7/site-packages/django/db/models/", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/Users/daishi/.virtualenvs/testdjango/lib/python2.7/site-packages/django/db/models/", line 697, in values
    clone = self._values(*fields, **expressions)
  File "/Users/daishi/.virtualenvs/testdjango/lib/python2.7/site-packages/django/db/models/", line 692, in _values
  File "/Users/daishi/.virtualenvs/testdjango/lib/python2.7/site-packages/django/db/models/sql/", line 1896, in set_values
    self.add_fields(field_names, True)
  File "/Users/daishi/.virtualenvs/testdjango/lib/python2.7/site-packages/django/db/models/sql/", line 1645, in add_fields
    name.split(LOOKUP_SEP), opts, alias, allow_many=allow_m2m)
  File "/Users/daishi/.virtualenvs/testdjango/lib/python2.7/site-packages/django/db/models/sql/", line 1417, in setup_joins
    names, opts, allow_many, fail_on_missing=True)
  File "/Users/daishi/.virtualenvs/testdjango/lib/python2.7/site-packages/django/db/models/sql/", line 1385, in names_to_path
    " not permitted." % (names[pos + 1], name))
FieldError: Cannot resolve keyword 'breed' into field. Join on 'data' not permitted.

I would expect the result to be ['labrador', 'collie'] (or the QuerySet equivalent thereof).

Change History (1)

comment:1 by Tim Graham, 7 years ago

Component: Uncategorizedcontrib.postgres
Resolution: duplicate
Status: newclosed
Type: UncategorizedNew feature

Duplicate of #28168 and #24747.

Note: See TracTickets for help on using tickets.
Back to Top