장고 어드민 필드값 개행

hyuckhoon.ko·2022년 5월 1일
0
from django.utils.html import format_html


@admin.register(YourModel)
class YourModelAdmin(admin.ModelAdmin):

    model = YourModel
    list_display = [
        "display_with_newline",
    ]

    def display_with_newline(self, obj):
        return format_html("<br>".join([
            str(
            	fixed_apply.fixed_match.get_label()
            ) for fixed_apply in obj.fixedmatchapply_set.all()
        ]))
    display_with_newline.short_description = "개행된 필드명"

    

0개의 댓글