diff --git a/backend/api/admin.py b/backend/api/admin.py index bd4a1dfd..1e7d4fc5 100644 --- a/backend/api/admin.py +++ b/backend/api/admin.py @@ -2,7 +2,8 @@ from django.contrib import admin from .models import (Category, Comment, Example, Label, Project, Role, RoleMapping, Seq2seqProject, SequenceLabelingProject, - Span, Tag, TextClassificationProject, TextLabel) + Span, Tag, TextClassificationProject, TextLabel, + AutoLabelingConfig) class LabelAdmin(admin.ModelAdmin): @@ -62,6 +63,18 @@ class CommentAdmin(admin.ModelAdmin): search_fields = ('user',) +class AutoLabelingConfigAdmin(admin.ModelAdmin): + list_display = ('project', 'model_name', 'model_attrs',) + ordering = ('project',) + + def get_readonly_fields(self, request, obj=None): + if obj: + return ["model_name"] + else: + return [] + + +admin.site.register(AutoLabelingConfig, AutoLabelingConfigAdmin) admin.site.register(Category, CategoryAdmin) admin.site.register(Span, SpanAdmin) admin.site.register(TextLabel, TextLabelAdmin) diff --git a/backend/api/models.py b/backend/api/models.py index 18d52f45..a27d05a4 100644 --- a/backend/api/models.py +++ b/backend/api/models.py @@ -339,7 +339,7 @@ class AutoLabelingConfig(models.Model): model_name = models.CharField(max_length=100) model_attrs = models.JSONField(default=dict) template = models.TextField(default='') - label_mapping = models.JSONField(default=dict) + label_mapping = models.JSONField(default=dict, blank=True) project = models.ForeignKey( to=Project, on_delete=models.CASCADE,