admin.py 674 B

12345678910111213141516171819202122232425
  1. from django.contrib import admin
  2. from .models import Release, ReleaseFile
  3. class ReleaseFileInlineAdmin(admin.TabularInline):
  4. model = ReleaseFile
  5. fields = ["file", "name"]
  6. can_delete = False
  7. def has_add_permission(self, request, obj=None):
  8. return False
  9. def has_change_permission(self, request, obj=None):
  10. return False
  11. class ReleaseAdmin(admin.ModelAdmin):
  12. search_fields = ["organization__name", "projects__name"]
  13. list_display = ["version", "organization"]
  14. list_filter = ["created"]
  15. autocomplete_fields = ["organization", "projects"]
  16. inlines = [ReleaseFileInlineAdmin]
  17. admin.site.register(Release, ReleaseAdmin)