About Administration Form Views

You can pass form values to administration views to prepopulate them.

For example, here is an admin action that redirects to announcement creation page:

1
2
3
4
5
6
7
@admin.action(description=_("Send announcement"))
def send_announcement(modeladmin, request, queryset):
    recipients = list(queryset.values_list("pk", flat=True))
    return redirect(
        reverse("admin:announcements_announcement_add")
        + f"?recipients={','.join(recipients)}"
    )

Tips and Tricks Programming Django 4.2 Django 3.2