render jsonschema as a form with django-jsonschema-form or django-schemulator

懵懂的女人 提交于 2019-12-05 18:49:52

The PageAdmin class goes in a file called admin.py, next to its corresponding model.py. Here are the Django 1.11 docs on discovering admin files.

You also have to register the admin for your model. You use the django.contrib.admin.register decorator for this. The same page has the docs for this decorator as well.

The usage goes something like

from somewhere import Page
from django.contrib import admin

# Overriding widgets for all instances of JSONField on PageAdmin form
@admin.register(Page)
class PageAdmin(admin.ModelAdmin):
    formfield_overrides = {
        JSONField: {'widget': JSONSchemaWidget(schema)}
    }

This code snippet registers your PageAdmin class as the ModelAdmin for your Page model.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!