[Answered ]-Django: Passing a queryset to another view with HttpResponseRedirect

2👍

There are two ways to do this.

1> If all you want do is filter by some fields in the model then you can pass the filters in url. Example: ‘/export/?id_gte=3&status_exact=3′

2> In your export action function you can set some variable or entire queryset in session and then check for it in you export view

def export(modeladmin, request, queryset):
    """
    not sure if this will work
    """
    request.session['export_querset'] = queryset

    """
    if above does not work then just set this and check for it in view and u can make the queryset again if this is set 
    """
    request.session['export_querset'] = 1
    return HttpResponseRedirect("/export/")
👤Rohan

Leave a comment