jmrivas86 / django-json-widget

An alternative widget that makes it easy to edit the new Django's field JSONField (PostgreSQL specific model fields)
MIT License
433 stars 88 forks source link

The widget doesn't work with inline #1

Closed dvarrazzo closed 5 years ago

dvarrazzo commented 7 years ago

Description

Trying to use the widget on a TabularInline, the generated page structure is broken. The "add another record" line gets merged into the widget dom.

Before using the widget:

json-widget-inline-pre

Using the widget:

json-widget-inline-post

What I Did

The attempt was just to use the widget in the formfield_overrides of the inline class, something like:

@admin.register(models.Allocation)
class Allocation(admin.ModelAdmin):

    class AllocationParams(admin.TabularInline):
        formfield_overrides = {
            JSONField: {'widget': JSONEditorWidget},
        }

    inlines = (AllocationParams, )
jmrivas86 commented 5 years ago

This issue was solved in https://github.com/jmrivas86/django-json-widget/pull/5

nostalgiaz commented 5 years ago

Are you sure? I have the same problem. This fix allows you to use different json fields on the same page but not different https://docs.djangoproject.com/en/2.1/ref/contrib/admin/#inlinemodeladmin-objects .

TimurKady commented 3 years ago

Yes, I am sure. Untitled-2