Add admin autocomplete, search fields and ordering to zone field in ZoneImageSegment
This commit is contained in:
parent
de0b5abb7b
commit
fe84079885
2 changed files with 15 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue