[Django] #32730: jsonify() method for Q class in django.db.models.query_utils

3 views
Skip to first unread message

Django

unread,
May 8, 2021, 10:20:18 PM5/8/21
to django-...@googlegroups.com
#32730: jsonify() method for Q class in django.db.models.query_utils
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
austinjhunt |
Type: New | Status: new
feature |
Component: Database | Version: 3.2
layer (models, ORM) | Keywords: query_utils,
Severity: Normal | jsonify, Q
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Hi,

I have written a new recursive method along with documentation and testing
that allows one to translate a Django Q object representing a complex
query into JSON format for the purpose of easily re-using and editing
complex queries that have been saved via pickling in a database. I am
opening this ticket so that I can reference it in an upcoming pull
request.

Thank you,
Austin

--
Ticket URL: <https://code.djangoproject.com/ticket/32730>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 8, 2021, 10:39:57 PM5/8/21
to django-...@googlegroups.com
#32730: jsonify() method for Q class in django.db.models.query_utils
-------------------------------------+-------------------------------------
Reporter: Austin Hunt | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: query_utils, | Triage Stage:
jsonify, Q | Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Austin Hunt):

* cc: Austin Hunt (added)
* has_patch: 0 => 1


Comment:

Pull request link: https://github.com/django/django/pull/14369

--
Ticket URL: <https://code.djangoproject.com/ticket/32730#comment:1>

Django

unread,
May 8, 2021, 10:40:17 PM5/8/21
to django-...@googlegroups.com
#32730: jsonify() method for Q class in django.db.models.query_utils
-------------------------------------+-------------------------------------
Reporter: Austin Hunt | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: query_utils, | Triage Stage:
jsonify, Q | Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Austin Hunt:

Old description:

> Hi,
>
> I have written a new recursive method along with documentation and
> testing that allows one to translate a Django Q object representing a
> complex query into JSON format for the purpose of easily re-using and
> editing complex queries that have been saved via pickling in a database.
> I am opening this ticket so that I can reference it in an upcoming pull
> request.
>
> Thank you,
> Austin

New description:

Hi,

I have written a new recursive method along with documentation and testing
that allows one to translate a Django Q object representing a complex
query into JSON format for the purpose of easily re-using and editing
complex queries that have been saved via pickling in a database. I am

opening this ticket so that I can reference it in a pull request.

https://github.com/django/django/pull/14369

Thank you,
Austin

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32730#comment:2>

Django

unread,
May 9, 2021, 4:27:07 PM5/9/21
to django-...@googlegroups.com
#32730: jsonify() method for Q class in django.db.models.query_utils
-------------------------------------+-------------------------------------
Reporter: Austin Hunt | Owner: Austin
| Hunt
Type: New feature | Status: assigned

Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: query_utils, | Triage Stage: Accepted
jsonify, Q |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Austin Hunt):

* owner: nobody => Austin Hunt
* status: new => assigned
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/32730#comment:3>

Django

unread,
May 9, 2021, 6:48:35 PM5/9/21
to django-...@googlegroups.com
#32730: jsonify() method for Q class in django.db.models.query_utils
-------------------------------------+-------------------------------------
Reporter: Austin Hunt | Owner: Austin
| Hunt
Type: New feature | Status: assigned
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: query_utils, | Triage Stage:
jsonify, Q | Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Accepted => Unreviewed


Comment:

It's not appropriate to accept your own ticket. Most probably it would be
more appropriate to release this as a third-party package (which of course
would have to be a function that takes a `Q` object) and see if it gains
widespread adoption, but I'll leave the ticket open for another opinion.

--
Ticket URL: <https://code.djangoproject.com/ticket/32730#comment:4>

Django

unread,
May 10, 2021, 12:14:47 AM5/10/21
to django-...@googlegroups.com
#32730: jsonify() method for Q class in django.db.models.query_utils
-------------------------------------+-------------------------------------
Reporter: Austin Hunt | Owner: Austin
| Hunt
Type: New feature | Status: closed

Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | Resolution: wontfix

Keywords: query_utils, | Triage Stage:
jsonify, Q | Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: assigned => closed
* resolution: => wontfix


Comment:

I agree with Tim. `Q()` is already deconstructible and pickleable so you
can use `pickle` to save and reuse existing `Q()` objects. I think that
support for editing `Q` objects by users is quite niche and it's not worth
the extra complexity. It sounds like a third-party package is the best way
to proceed.

--
Ticket URL: <https://code.djangoproject.com/ticket/32730#comment:5>

Reply all
Reply to author
Forward
0 new messages