How to add readonly inline on django admin

前端 未结 4 1020
被撕碎了的回忆
被撕碎了的回忆 2021-02-01 13:01

I am using django 1.4 and I have a many2many field, so when creating the admin site I wanted to add this field as an inline, here is some code:

class SummaryInli         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-01 13:38

    Thanks Keval Prabhu

    class UnitsInline(admin.TabularInline):
        model = Units
        extra = 0
        verbose_name = 'Units'
        verbose_name_plural = 'Units of company'
    
        **def has_add_permission(self, request, obj=None):
            return False
        def has_delete_permission(self, request, obj=None):
            return False**
    

提交回复
热议问题