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
440 stars 88 forks source link

Added new attribute to support select default rendering mode #6

Closed WqyJh closed 6 years ago

WqyJh commented 6 years ago

I've add an attribute to the JSONEditorWidget, which allows users to choose the default rendering mode. This also solve the issue #2 .

    from django import forms
    from django_json_widget.widgets import JSONEditorWidget
    from .models import YourModel

    class YourForm(forms.ModelForm):
        class Meta:
            model = YourModel

            fields = ('jsonfield',)

            widgets = {
                # choose one mode from ['text', 'code', 'tree', 'form', 'view']
                'jsonfield': JSONEditorWidget(mode='code')
            }
jmrivas86 commented 6 years ago

LGTM, thanks for your PR.

cnr91 commented 1 month ago

thank you