如何在django管理界面中获得弹出窗口?

时间:2016-04-12 07:46:42

标签: python django python-2.7 django-admin

我分别在admin.py文件中有以下代码。当我点击删除链接我不想直接删除页面。我只想要一个弹出窗口显示(你确定吗?)。有什么办法吗?如果是这样,请在此提及。

def delete_link(self, obj):
        info = obj._meta.app_label, obj._meta.model_name
        url = reverse('admin:%s_%s_delete' % info, args=(obj.id,))

        return '<a href="%s">Delete</a>' % url

  delete_link.allow_tags = True
  delete_link.short_description = 'Delete'

def action_link(self, obj):            

        app_name = obj._meta.app_label
        url_name = obj._meta.model_name
        data_id = obj.id

                 return """
            <ul>

               <li><a href="/admin/{0}/{1}/{2}/delete">Delete</a></li>

            </ul>
            """.format(
            obj._meta.app_label, 
            obj._meta.model_name, 
            obj.id)
  action_link.allow_tags = True
  action_link.short_description = 'Actions'

0 个答案:

没有答案