From a3ba79c02ecfc6b59020be1e6d8249e26badc194 Mon Sep 17 00:00:00 2001 From: Floris272 Date: Tue, 7 Jan 2025 14:45:29 +0100 Subject: [PATCH] Add JsonSchemaAdmin --- django_json_schema/admin.py | 6 ++++++ django_json_schema/models.py | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 django_json_schema/admin.py diff --git a/django_json_schema/admin.py b/django_json_schema/admin.py new file mode 100644 index 0000000..27e0276 --- /dev/null +++ b/django_json_schema/admin.py @@ -0,0 +1,6 @@ +from django.contrib import admin +from .models import JsonSchema + +@admin.register(JsonSchema) +class JsonSchemaAdmin(admin.ModelAdmin): + search_fields = ['name'] diff --git a/django_json_schema/models.py b/django_json_schema/models.py index 880d384..dce2ae2 100644 --- a/django_json_schema/models.py +++ b/django_json_schema/models.py @@ -19,6 +19,9 @@ class Meta: verbose_name = _("Json schema") verbose_name_plural = _("Json Schemas") + def __str__(self): + return self.name + def validate(self, json: dict) -> None: try: validate(json, self.schema)