abogushov / django-admin-json-editor

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

Unknown theme #30

Closed cyberbudy closed 4 years ago

cyberbudy commented 4 years ago

When using default theme 'bootstrap3' I have an error in console "Unknown theme bootstrap3"

Gustik commented 4 years ago

I don’t get the form, is it due to a theme error, or am I mistaken somewhere? in the dev console i see:

Uncaught Error: Unknown theme bootstrap3 at new Z (jsoneditor.min.js:18) at (index):241

my code:

DATA_SCHEMA = {
    'type': 'array',
    "title": "Смета",
    "format": "table",
    "items": {
        "type": "object",
        "title": "Смета",
        "properties": {
            "name": {
                'title': 'Критерий',
                "type": "string"
            },
            "cost": {
                "type": "number"
            }
        }
    }
}

class ReportSmetaAdminForm(forms.ModelForm):
    class Meta:
        model = Report
        fields = '__all__'
        widgets = {
            'smeta': JSONEditorWidget(DATA_SCHEMA, collapsed=False),
        }

@admin.register(Report)
class ReportAdmin(admin.ModelAdmin):
    list_display = ('project', 'status',)
    form = ReportSmetaAdminForm
abogushov commented 4 years ago

New json-editor does not support bootstrap 3 now. As workaround it is possible to use the html theme. I am going to update plugin to use bootstrap 4 as default.

Gustik commented 4 years ago

how to use html theme?

abogushov commented 4 years ago

It is possible to pass any options into JSONEditor via the editor_options parameter of JSONEditorWidget. widget = JSONEditorWidget(schema, False, editor_options={'theme': 'html'})

abogushov commented 4 years ago

@Gustik @cyberbudy check 0.2.3 version please. It uses bootstrap 4

Gustik commented 4 years ago

thank you, it works!