admin.py 1023 Bytes
Newer Older
1
from django.contrib import admin
2
3

from django import forms
4
from .models import Specimen, SpecimenLocation, Person, Fixation
5
6
7
8
9
10
11
12
13
14
from .widgets import LatLongWidget


# Custom form to provide lat/lon widget instead of OL map.
class MyAdminForm(forms.ModelForm):

    class Meta:
        model = Specimen
        fields = "__all__"
        widgets = {
15
            'coords': LatLongWidget
16
17
        }

18
19

class SpecimenAdmin(admin.ModelAdmin):
20
    form = MyAdminForm
21

22
23
24
25
26
27
28
29
30
31
32
33
34
    list_display = ('specimen_id', 'scientific_name', 'identified_by', 'specimen_location', 'depth', 'fixation')
    list_filter = ('identified_by', 'specimen_location', 'fixation')
    search_fields = ['scientific_name']

class SpecimenLocationAdmin(admin.ModelAdmin):
    pass

class PersonAdmin(admin.ModelAdmin):
    pass

class FixationAdmin(admin.ModelAdmin):
    pass

35
admin.site.register(Specimen, SpecimenAdmin)
36
37
38
admin.site.register(SpecimenLocation, SpecimenLocationAdmin)
admin.site.register(Person, PersonAdmin)
admin.site.register(Fixation, FixationAdmin)