Issue with Custom Admin Action - 'apply' Not Present in request.POST

I am currently facing an issue with a custom action in the Django admin panel that I have implemented to update product prices based on a user-defined percentage. The action is triggered, but it seems that the form is not being submitted correctly, as the expected value 'apply' is not present in request.POST.

When I check the request data after submitting the form, I see the following output in my logs:

Request method: POST
Request POST data: <QueryDict: {‘csrfmiddlewaretoken’: […], ‘action’: [‘alterar_precos’], ‘select_across’: [‘0’], ‘index’: [‘0’], ‘_selected_action’: [‘83’]}>

As you can see, there is no 'apply' key in request.POST, which indicates that the form submission is not working as expected.

Has anyone encountered a similar problem? What could be preventing the 'apply' key from being included in request.POST during form submission?Thank you for your help!

class AtualizarPrecoForm(forms.Form):
    percentual = forms.DecimalField(
        max_digits=5,
        decimal_places=2,
        label="Percentual de alteração (%)",
        help_text="Insira um valor positivo para aumento ou negativo para redução."
    )
@admin.action(description="Alterar preço dos produtos selecionados")
def alterar_precos(modeladmin, request, queryset):
    """
    Ação personalizada para alterar o preço dos produtos com base em um percentual informado pelo usuário.
    """
    print("Ação alterar_precos chamada")
    print("Request method:", request.method)
    print("Request POST data:", request.POST)

    form = AtualizarPrecoForm()  # Inicializa o formulário aqui

    if request.method == 'POST':
        print("POST request detected")
        if 'apply' in request.POST:
            print("'apply' found in POST data")
            form = AtualizarPrecoForm(request.POST)
            if form.is_valid():
                print("form is valid")
                percentual = form.cleaned_data['percentual']
                fator = 1 + (percentual / 100)  # Fator de multiplicação
                # Atualiza os preços diretamente no banco de dados
                queryset.update(preco=F('preco') * fator)
                messages.success(request, f"Preços atualizados em {percentual}% para os produtos selecionados.")
                return None
            else:
                print("Form errors:", form.errors)
        else:
            print("'apply' not found in POST data")
    else:
        print("Request method is not POST")

    # Renderiza o formulário no admin
    return render(
        request,
        'admin/atualizar_precos.html',
        {
            'form': form,
            'queryset': queryset,
            'opts': modeladmin.model._meta,
            'action_checkbox_name': admin.helpers.ACTION_CHECKBOX_NAME,
        },
    )

I might have missed something obvious, but why do you think there should be an “apply” field in the submitted data?

I don’t see it anywhere in the docs for admin actions.

You are right, there should not be an “apply” field in the submitted data. The problem is that the form is not valid and I can’t see the cause.