admin.py 685 B

1234567891011121314151617181920212223
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. from django.contrib import admin
  4. from .models import ItemType, Item, Loan
  5. admin.site.register(ItemType)
  6. @admin.register(Item)
  7. class ItemAdmin(admin.ModelAdmin):
  8. list_display = ('type', 'designation', 'mac_address', 'user_in_charge',
  9. 'buy_date', 'is_available')
  10. list_filter = ('type__name', 'buy_date')
  11. search_fields = ('designation', 'user_in_charge')
  12. @admin.register(Loan)
  13. class LoanAdmin(admin.ModelAdmin):
  14. list_display = ('item', 'user', 'loan_date', 'loan_date_end', 'location')
  15. list_filter = ('item__designation', 'user__username')
  16. search_fields = ('item', 'user')