关于动作管理文件Django?

时间:2014-09-23 06:18:57

标签: django action admin

如何发送param而不是POST但是从GET发送到action do_send

class BlogAdminCategory(admin.ModelAdmin):

    def do_send(self, request, queryset):
        response = HttpResponse(content_type="application/json")
        serializers.serialize("json", queryset, stream=response)
        return response
    do_send.short_description = 'Hide'

    actions = [
        do_send
    ]
    save_on_top= True
    list_display =('title_category','pub_date','hide_me',)

    def hide_me(self, obj):
        # how to send param not  POST but from  GET category to action do_send
        return '<a href="send_do?id={0}">Hide</a>'.format(obj.id)  

    hide_me.short_description = 'Hide'
    hide_me.allow_tags = True

1 个答案:

答案 0 :(得分:0)

你做不到。当您在管理员中执行操作时,您正在POST一个表单,该表单包含您选择要执行的操作的那些对象的值。它不能作为GET

https://github.com/django/django/blob/master/django/contrib/admin/options.py#L1240

  

处理管理员操作。如果请求被POST到了,则调用此方法   更改列表;如果处理了动作,它会返回一个HttpResponse,并且   否则没有。