Browse Source

Better search, filtering, and display.

feature/upgrade-admin-visits
Drew Larson 8 years ago
parent
commit
8a1fcda9a1
  1. 14
      bikeshop_project/core/admin.py

14
bikeshop_project/core/admin.py

@ -7,5 +7,17 @@ admin.site.register([Membership, Payment])
@admin.register(Visit) @admin.register(Visit)
class VisitAdmin(admin.ModelAdmin): class VisitAdmin(admin.ModelAdmin):
list_select_related = ('member',)
fields = ('member', 'purpose', 'created_at')
ordering = ('created_at',) ordering = ('created_at',)
list_display = ('member', 'purpose', 'created_at') list_display = ('full_name', 'purpose', 'created_at')
list_filter = (
('purpose', admin.ChoicesFieldListFilter),
)
search_fields = ['member__email', 'member__last_name', 'member__first_name']
def full_name(self, obj):
return obj.member.full_name
full_name.admin_order_field = 'member__last_name'

Loading…
Cancel
Save