Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

216
Visualizações
How to pass on django form results to a text box

I haven't been coding for more than a year now and am being a little rusty on some aspects. I have a django form designed using crispy_forms. Nothing very original : a bunch of radiobuttons, textbox...

Goal: My purpose is to have a generate_report button that once being clicked on open below the button a textbox with a text generated using the values picked for the former fields.

I created in models a __str__ method with the text I want. But I'm not sure that's the proper place for such a function.

I can have a text box hidden that only shows once someone click on the generate_report button using javascript, but I don't know how to pass on the text with the data. Any idea?

[forms.py]

from .models import Foo
from crispy_forms import bootstrap, helper, layout

class FooForm(forms.ModelForm):

    class Meta:
        model = Foo
        fields = "__all__"

    def __init__(self, request, *args, **kwargs):
        self.request = request
        super().__init__(*args, **kwargs)

    actions = bootstrap.FormActions(layout.Submit("save", _("Save")),
                                    bootstrap.StrictButton("generate_report", css_class="btn-success"))

    self.helper = helper.FormHelper()
    self.helper.form_action = self.request.path
    self.helper.form_method = "POST"
    self.helper.form_class = "blueForms"
    self.helper.layout = layout.Layout(
        field1,
        field2,
        field3,
        actions
    )
    self.form_tag = False
    self.render_required_fields = False
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda