In an admin.py I have setup an action called export as you can see below…
class RecipientAdmin(admin.ModelAdmin):
actions = [export]
export.short_description = "Export Stuff"
admin.site.register(Recipient, RecipientAdmin)
This runs the following function…
def export(modeladmin, request, queryset):
return HttpResponseRedirect("/export/")
My question is…
How can I pass the queryset to another view/page it is possible using HttpResponseRedirect? or is there another way I should try to do this?
I want the records that have been preselected on the list view to be carried to the new page so I can iterate over them.
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