How to get data from forms in formset, while formset won't validate from django admin custom actions interim form page

I don't know how to get the updated fields, from the forms in the formset, into individual messages, because the formset is never valid.

I've already tried the "for form in formset" inside and outside the form.is_valid() with .get['field'], .get('field'), and cleaned_data.

in the admin action interim page the user has to be able to see and edit the forms intial values and when they submit the messages should be sent with the form updated or not values to the correct mail. But the formset is never valid. Is it because of how the admin actions functions or what is going on?


class ReviewRequestTemplate(forms.Form):
    emailtemplate = forms.CharField(widget=forms.Textarea)
    employers_email = forms.EmailField()
    review_link = forms.CharField()
    subject = forms.CharField()

class EmployerAdmin(TranslationAdmin):
    list_display = ('name', 'website', 'review_request_sent',)
    actions = ['request_review',]

    def request_review(self, request, queryset):
        RequestTemplateFormset = formset_factory(ReviewRequestTemplate, extra=0)
        #formset initial is a list comprehension
        #for employer in queryset
        formset = RequestTemplateFormset(initial=[{'emailtemplate': f"Hello {} Review our servie right NOW! Here is your link:",'employers_email', 'review_link':get_current_site(request).domain +reverse('review', kwargs={'uidb64': urlsafe_base64_encode(force_bytes(, 'token':account_activation_token.make_token(employer)}), 'subject':'Please let us better our services'} for employer in queryset])

        if request.POST.get('post'):
            formset = RequestTemplateFormset(request.POST)

            if formset.is_valid():
                message = f"email:{form.get('employers_email')}, subject:{form.get('subject')}, message: {form.get('emailtemplate') + form.get('review_link')}"
                print('not valid')

            all_sent = request.POST.items()
            return HttpResponse(all_sent)
            context = {
                'title': "Are you sure?",
                'queryset': queryset,
                'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME,
                'formset': formset
            return TemplateResponse(request, 'admin/requestreview.html', #TemplateResponse
    request_review.short_description = "Send review requests"


{% extends "admin/base_site.html" %}
{% load i18n l10n %}

{% block content %}
<form action="" method="post">{% csrf_token %}
    {{ formset.errors }}
    <p>The following videos will be accepted:</p>

    <ul>{{ queryset|unordered_list }}</ul>

    {% for obj in queryset %}
    <input type="hidden" name="{{ action_checkbox_name }}" value="{{|unlocalize }}" />
    {% endfor %}
    <input type="hidden" name="action" value="request_review" />
    <input type="hidden" name="post" value="yes" />
    <input type="submit" value="{% trans "Yes, I'm sure" %}" />

    {%for form in formset%}
{% endblock %}
Back to Top