Django Admin Actions on single object

前端 未结 4 836
春和景丽
春和景丽 2021-01-01 22:41

The admin actions seem to work on several items selected in the list view of django admin interface:

In my case I would like to have a simple action button on the ch

4条回答
  •  無奈伤痛
    2021-01-01 22:52

    If you realy need per-single object, I suggest you to use this solution, eg:

    class Gallery(TimeStampedModel):
        title = models.CharField(max_length=200)
        attachment = models.FileField(upload_to='gallery/attachment/%Y/%m/%d')
    
        def __str__(self):
            return self.title
    
        def process_button(self):
            return ('
提交回复
热议问题