diff --git a/backend/right_tree/api/admin.py b/backend/right_tree/api/admin.py index cf5b649..bd8b267 100644 --- a/backend/right_tree/api/admin.py +++ b/backend/right_tree/api/admin.py @@ -1,6 +1,16 @@ from django.contrib import admin import right_tree.api.models as models + +class ZoneAdmin(admin.ModelAdmin): + ordering = ['name', 'variant', 'refined_variant', 'id'] + search_fields = ['name', 'variant', 'refined_variant', 'id'] + + +class ZoneImageSegmentAdmin(admin.ModelAdmin): + autocomplete_fields = ['zone'] + + admin.site.register(models.Plant) admin.site.register(models.SoilOrder) admin.site.register(models.SoilLayer) @@ -10,5 +20,5 @@ admin.site.register(models.EcologicalDistrictLayer) admin.site.register(models.ToleranceLevel) admin.site.register(models.HabitatImage) admin.site.register(models.Habitat) -admin.site.register(models.Zone) -admin.site.register(models.ZoneImageSegment) +admin.site.register(models.Zone, ZoneAdmin) +admin.site.register(models.ZoneImageSegment, ZoneImageSegmentAdmin) diff --git a/backend/right_tree/api/models.py b/backend/right_tree/api/models.py index cbbcda0..25cf16a 100644 --- a/backend/right_tree/api/models.py +++ b/backend/right_tree/api/models.py @@ -82,6 +82,9 @@ class Zone(models.Model): variant_str = f"({self.variant}{refined_variant_str})" if self.variant is not None else "" return f"{self.name} {variant_str}" + class Meta: + ordering = ['name', 'variant', 'refined_variant', 'id'] + class ZoneImageSegment(models.Model): zone = models.ForeignKey(