Skip to content

Commit

Permalink
Add JsonSchemaAdmin
Browse files Browse the repository at this point in the history
  • Loading branch information
Floris272 committed Jan 7, 2025
1 parent bd08ca6 commit a3ba79c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions django_json_schema/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.contrib import admin
from .models import JsonSchema

@admin.register(JsonSchema)
class JsonSchemaAdmin(admin.ModelAdmin):
search_fields = ['name']
3 changes: 3 additions & 0 deletions django_json_schema/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a3ba79c

Please sign in to comment.