Fix SpeciesRange admin listing
This commit is contained in:
parent
1f52df987e
commit
688adfac42
2 changed files with 14 additions and 2 deletions
14
app/admin.py
14
app/admin.py
|
@ -125,6 +125,18 @@ class PeopleRangeAdmin(admin.ModelAdmin):
|
|||
return str(obj.range.name)
|
||||
|
||||
|
||||
class SpeciesRangeAdmin(admin.ModelAdmin):
|
||||
model = SpeciesRange
|
||||
search_fields = ['scientific_name__scientific_name', 'range__range_name']
|
||||
list_display = ['scientific_name', 'range_name']
|
||||
|
||||
def scientific_name(self, obj):
|
||||
return str(obj.scientific_name.scientific_name) if obj and obj.scientific_name and obj.scientific_name.scientific_name else '--'
|
||||
|
||||
def range_name(self, obj):
|
||||
return str(obj.range) if obj.range else '--'
|
||||
|
||||
|
||||
class RangeCountryAdmin(admin.ModelAdmin):
|
||||
model = RangeCountry
|
||||
search_fields = ['range__range_name', 'country__short_name']
|
||||
|
@ -178,7 +190,7 @@ admin.site.register(TaxaPeople)
|
|||
admin.site.register(ScalesPeople)
|
||||
admin.site.register(Species, SpeciesAdmin)
|
||||
admin.site.register(PeopleFunction)
|
||||
admin.site.register(SpeciesRange)
|
||||
admin.site.register(SpeciesRange, SpeciesRangeAdmin)
|
||||
admin.site.register(RangesPeople, PeopleRangeAdmin)
|
||||
admin.site.register(TaxonRange, TaxonRangeAdmin)
|
||||
admin.site.register(PeopleResource)
|
||||
|
|
|
@ -648,7 +648,7 @@ class SpeciesRange(models.Model):
|
|||
source_url = models.TextField(blank=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.scientific_name.scientific_name
|
||||
return self.scientific_name.scientific_name if self and self.scientific_name else ' -- '
|
||||
|
||||
|
||||
class PeopleRange(models.Model):
|
||||
|
|
Loading…
Reference in a new issue