abogushov / django-admin-json-editor

Adds json-editor for JSONField in Django Administration
MIT License
173 stars 61 forks source link

Json editor in StackedInline #1

Open Fercho191 opened 6 years ago

Fercho191 commented 6 years ago

Hello! Thanks for the work in this repository, it works great!

I had a problem and I did not know how to fix it:

I tried to place the form in an admin.StackedInline, then add it to anadmin.ModelAdmin

the template worked correctly with the schema, however, sending the form caused error because the field was in None.

class AnotherModelAdminForm(ModelForm):
    class Meta:
        model = AnotherModel
        fields = '__all__'
        widgets = {
            'json_field': JSONEditorWidget(SCHEMA, collapsed=False),
        }
class AnotherModelAdmin(admin.StackedInline):
    model = AnotherModel
    form = AnotherModelAdminForm

@admin.register(MyModel)
class MyModelAdmin(admin.ModelAdmin):
    inlines = [
        AnotherModelAdmin,
    ]

Can you think of a solution?

Thanks in advance

abogushov commented 6 years ago

Hello. Thanks for your words! There is problem with js during binding editor. I will try to solve this and, if I succeed, I will add an example.

Thanks for the issue.

linhfishCR7 commented 1 year ago

Hello. Thanks for your words! There is problem with js during binding editor. I will try to solve this and, if I succeed, I will add an example.

Thanks for the issue.

Has this problem been solved yet? Thanks