I would like to customize Admin page for my
How can I add new button (just beside the “ADD NEWSLETTER SUBSCRIBER +”) and assign specific action to this button ?
The idea behind is that I would like to have functionality to export string (and show it to user with
HttpResponse) with multiple email addresses separated by comma (later I’ll be pasting this string directly into TO field when sending emails).
I already tried to implement this using Django Admin Actions but unfortunately I’m getting WARNING:
Items must be selected in order to perform actions on them. No items have been changed.
So if this would be easier, for me the option is also to bypass this WARNING - if that’s possible.
But I don’t want to make selections to perform this action because I don’t use
queryset and I don’t care about selected items but I use specific query to retrieve needed objects for exporting.
Here is what I tried to do using Django Admin Actions:
def export_newsletter_subscribers(modeladmin, request, queryset): emails =  ns = NewsletterSubscriber.objects.filter(has_consented=True) for n in ns: emails.append(n.email) emails_string = "," emails_string = emails_string.join(emails) response = HttpResponse(emails_string) return response export_newsletter_subscribers.short_description = "Export Newsletter Subscribers"