#26748 closed Cleanup/optimization (fixed)
Ease customizing the JSONField widget
| Reported by: | Charlie Denton | Owned by: | |
|---|---|---|---|
| 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:1 by , 9 years ago
comment:2 by , 9 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|---|
| Type: | Uncategorized → Cleanup/optimization |
| Version: | 1.9 → master |
comment:3 by , 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:5 by , 9 years ago
This will be in 1.11, see our supported versions policy for details on the backport policy.
comment:6 by , 9 years ago
| Summary: | Custom widget on JSONField in contrib.postgres: simplification → Ease customizing the JSONField widget |
|---|
Patch submitted https://github.com/django/django/pull/6764