Django Admin inline for recursive ManyToMany

前端 未结 1 436
野的像风
野的像风 2021-02-07 16:11

I have the following model with a many-to-many relationship to itself

class Ticket(models.Model):

    STATUS = (
        (0, \"Open\"),
        (1, \"Closed\"),         


        
相关标签:
1条回答
  • 2021-02-07 16:44

    May be its' to late, but I try answer this question. Ticket.replies.through is a table to manage many-to-many relations, it has fields from_ticket and to_ticket(FK to model Ticket) and you can set this fields as option fk_name for TabularInline.

    class TicketReply(admin.TabularInline):
        model = Ticket.replies.through
        fk_name = 'from_ticket'
    
    0 讨论(0)
提交回复
热议问题