[Django] #26748: Custom widget on JSONField in contrib.postgres: simplification

17 views
Skip to first unread message

Django

unread,
Jun 12, 2016, 4:31:59 PM6/12/16
to django-...@googlegroups.com
#26748: Custom widget on JSONField in contrib.postgres: simplification
----------------------------------+-----------------
Reporter: meshy | Owner:
Type: Uncategorized | Status: new
Component: contrib.postgres | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 1 | UI/UX: 0
----------------------------------+-----------------
On normal form fields, one can customise the widget with an attribute of
the field. eg:

{{{
class CoffeeField(django.forms.CharField):
widget = CoffeeWidget

>>> CoffeeField().widget
<CoffeeWidget object at 0xc0ffeec0ffee>
}}}

However, with `contrib.postgres.forms.jsonb.JSONField` this doesn't work.
Instead, once must override `__init__()` or pass `widget` in as a kwarg.


Luckily, it's pretty easy to fix, and I've almost completed writing a
patch. I'll link to it here once done.

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

Django

unread,
Jun 12, 2016, 4:37:43 PM6/12/16
to django-...@googlegroups.com
#26748: Custom widget on JSONField in contrib.postgres: simplification
----------------------------------+--------------------------------------

Reporter: meshy | Owner:
Type: Uncategorized | Status: new
Component: contrib.postgres | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by meshy):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Patch submitted https://github.com/django/django/pull/6764

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

Django

unread,
Jun 12, 2016, 4:57:20 PM6/12/16
to django-...@googlegroups.com
#26748: Custom widget on JSONField in contrib.postgres: simplification
--------------------------------------+------------------------------------
Reporter: meshy | Owner:
Type: Cleanup/optimization | Status: new
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by charettes):

* version: 1.9 => master
* type: Uncategorized => Cleanup/optimization
* stage: Unreviewed => Accepted


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

Django

unread,
Jun 12, 2016, 5:15:35 PM6/12/16
to django-...@googlegroups.com
#26748: Custom widget on JSONField in contrib.postgres: simplification
--------------------------------------+------------------------------------
Reporter: meshy | Owner:
Type: Cleanup/optimization | Status: new
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by meshy):

Thank you for accepting the patch, charettes :)

I'm curious what the policy is here -- will this be backported into
existing versions, or will this become available when 1.10 comes out?

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

Django

unread,
Jun 13, 2016, 8:10:27 AM6/13/16
to django-...@googlegroups.com
#26748: Custom widget on JSONField in contrib.postgres: simplification
-------------------------------------+-------------------------------------
Reporter: meshy | Owner: Tim
Type: | Graham <timograham@…>
Cleanup/optimization | Status: closed
Component: contrib.postgres | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* owner: => Tim Graham <timograham@…>
* resolution: => fixed


Comment:

In [changeset:"f2c0eb19e961f5864573251e70bdcdecd0250aed" f2c0eb19]:
{{{
#!CommitTicketReference repository=""
revision="f2c0eb19e961f5864573251e70bdcdecd0250aed"
Fixed #26748 -- Allowed overriding JSONField's widget with an attribute.
}}}

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

Django

unread,
Jun 13, 2016, 8:11:38 AM6/13/16
to django-...@googlegroups.com
#26748: Custom widget on JSONField in contrib.postgres: simplification
-------------------------------------+-------------------------------------
Reporter: meshy | Owner: Tim
Type: | Graham <timograham@…>
Cleanup/optimization | Status: closed
Component: contrib.postgres | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by timgraham):

This will be in 1.11, see our
[https://docs.djangoproject.com/en/dev/internals/release-process
/#supported-versions supported versions policy] for details on the
backport policy.

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

Django

unread,
Jun 13, 2016, 8:12:31 AM6/13/16
to django-...@googlegroups.com
#26748: Ease customizing the JSONField widget

-------------------------------------+-------------------------------------
Reporter: meshy | Owner: Tim
Type: | Graham <timograham@…>
Cleanup/optimization | Status: closed
Component: contrib.postgres | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/26748#comment:6>

Django

unread,
Jun 14, 2016, 11:48:32 AM6/14/16
to django-...@googlegroups.com
#26748: Ease customizing the JSONField widget
-------------------------------------+-------------------------------------
Reporter: meshy | Owner: Tim
Type: | Graham <timograham@…>
Cleanup/optimization | Status: closed
Component: contrib.postgres | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by meshy):

Great! Thanks for the link `:)`

--
Ticket URL: <https://code.djangoproject.com/ticket/26748#comment:7>

Reply all
Reply to author
Forward
0 new messages