Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

214
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!