Cannot pass GET parameters to django admin custom action view

20 views Asked by At

GET parameters seem to always return empty when attempting to retrieve them from the action view. For example when I add the parameter 'form1' to the form action url, it is missing when I access the request.GET object in the action view. Is it possible to access GET parameters in the action view method somehow?

@admin.register(FormDefinition)
class FormDefinitionAdmin(BaseAdmin):
    actions = ('export_forms')
    
    def export_forms(self, request, queryset):
        # returns empty here
        form_name = request.GET.get('form_name')
        exporter = FormExporter()
        file_path = exporter.export_form(form_name)
        with open(file_path, 'r') as file:
            response = HttpResponse(file, content_type='application/pdf')
            response["Content-Disposition"] = "attachment; filename=forms.json"
            return response
0

There are 0 answers