Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#26748 closed Cleanup/optimization (fixed)

Ease customizing the JSONField widget

Reported by: Charlie Denton Owned by: Tim Graham <timograham@…>
Component: contrib.postgres Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

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.

Change History (7)

comment:2 by Simon Charette, 9 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization
Version: 1.9master

comment:3 by Charlie Denton, 9 years ago

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?

comment:4 by Tim Graham <timograham@…>, 9 years ago

Owner: set to Tim Graham <timograham@…>
Resolution: fixed
Status: newclosed

In f2c0eb19:

Fixed #26748 -- Allowed overriding JSONField's widget with an attribute.

comment:5 by Tim Graham, 9 years ago

This will be in 1.11, see our supported versions policy for details on the backport policy.

comment:6 by Tim Graham, 9 years ago

Summary: Custom widget on JSONField in contrib.postgres: simplificationEase customizing the JSONField widget

comment:7 by Charlie Denton, 9 years ago

Great! Thanks for the link :)

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