old_contents: from __future__ import absolute_import
  from django.contrib import admin
  from django.http import HttpResponse
  from .models import Donor, Donation
  
  class DonationInline(admin.TabularInline):
      model = Donation
      extra = 0
  
  @admin.register(Donor)
  class DonorAdmin(admin.ModelAdmin):
      inlines = [
          DonationInline
      ]
      # date_hierarchy = 'last_donation'
      actions_on_bottom = True
      list_display = 'name', 'business', #'last_donation'
      search_fields = 'name', 'business', 'email', 'address'
  
      def make_list(self, request, queryset):
          response = HttpResponse(content_type="text/plain")
          response['Content-Disposition'] = 'attachment; filename=donors.txt'
          for donor in queryset:
              if donor.email:
                  response.write("{} <{}>\n".format(donor.name, donor.email))
          return response
      make_list.short_description = "Create mailing list (plain text)"
  
      actions = [make_list]
  
new_contents: from __future__ import absolute_import
  from django.contrib import admin
  from django.http import HttpResponse
  from .models import Donor, Donation
  
  class DonationInline(admin.TabularInline):
      model = Donation
      extra = 0
  
  @admin.register(Donor)
  class DonorAdmin(admin.ModelAdmin):
      inlines = [
          DonationInline
      ]
      # date_hierarchy = 'last_donation'
      actions_on_bottom = True
      list_display = 'name', 'business', 'last_donation'
      search_fields = 'name', 'business', 'email', 'address'
  
      def last_donation(self, obj):
          return obj.donation_set.latest().when
  
  
      def make_list(self, request, queryset):
          response = HttpResponse(content_type="text/plain")
          response['Content-Disposition'] = 'attachment; filename=donors.txt'
          for donor in queryset:
              if donor.email:
                  response.write("{} <{}>\n".format(donor.name, donor.email))
          return response
      make_list.short_description = "Create mailing list (plain text)"
  
      actions = [make_list]
  
subject: Add (inefficient) last_donation to admin