Django Admin TabularInline에 링크 추가

2021. 3. 3. 21:52파이썬/Django

class TestedBoxInline(admin.TabularInline) :
    model = Tested_Data_Box
    extra = 0
    fields = ['id','getBoxLink','char','coords_1','coords_2','coords_3','coords_4','page']
    readonly_fields = ['getBoxLink','char','coords_1','coords_2','coords_3','coords_4','page']

    def getBoxLink(self, obj) :
        return format_html("<a href='%s'>%s</a>" %(reverse('admin:%s_trained_box_change' %obj._meta.app_label,args=(obj.box_id,)), obj.box_id))
    getBoxLink.short_description = 'Traned Box'

 

'파이썬 > Django' 카테고리의 다른 글

Django Admin form 데이터  (0) 2021.03.04
Django admin reverse  (0) 2021.03.03
Django Admin 에러  (0) 2021.02.21
Django queryset distinct  (0) 2021.02.20
Django PostgreSQL 연동시 에러  (0) 2021.02.19