How to use django crispy forms forms

currently when I run my app, am promoted to enter data from the terminal which i dont want eg Enter Loan Ammount

`from .forms import BasicForm` `def signup(request):`
`    if request.method == 'POST':`
`        form = BasicForm(request.POST)`
`        if form.is_valid():`
`                # Entering the loan amount`
`            isCorrectAmount = True`
`            while isCorrectAmount:`
`                enteredLoanAmount = request.POST.get(float(input("Enter Loan amount (Min - 1,000,000): ")))`
`                if enteredLoanAmount < 1_000_000:`
`                    print("Minimum Loan amount is 1,000,000")`
`                    enteredLoanAmount = float(input("Enter Loan amount (Min - 1,000,000): "))`
`                else:`
`                    isCorrectAmount = False`
`                    `
`            # Entering the age`
`            isCorrectAge = True`
`            while isCorrectAge:`
`                enteredAge = int(input("Enter Age (18 - 50 years): "))`
`                if enteredAge < 18 or enteredAge > 50:`
`                    print("Sorry, age does not meet criteria!")`
`                    enteredAge = int(input("Enter Age (18 - 50 years):"))`
`                else:`
`                    isCorrectAge = False` `            # Entering the loan term`
`            isCorrectTerm = True`
`            while isCorrectTerm:`
`                enteredTerm = int(input("Enter Loan term (3 - 35 years): "))`
`                if enteredTerm < 3 or enteredTerm > 35:`
`                    print("Sorry, loan term does not meet criteria!")`
`                    enteredTerm = int(input("Enter Loan term (3 - 35 years):"))`
`                else:`
`                    isCorrectTerm = False`
`                    `
`            # Entering the gender`
`            enteredGender = input("Enter Gender (MALE or FEMALE): ")`

I would like to stop this and enter data using my form not the terminal and my form looks something like this

`class BasicForm(forms.Form):`
`    GENDERS = (`
`        ('M', 'Male'),`
`        ('F', 'Female')`
`    )`
`    enteredLoanAmount = forms.CharField()`
`    Enter_age = forms.CharField()`
`    Enter_loan_term = forms.CharField()`
`    gender = forms.ChoiceField(widget=forms.RadioSelect, choices=GENDERS)`
`    # We should use a validator to make sure `
`    # the user enters a valid number format`
`    ` `    def __init__(self,*args, **kwargs): `
`        super().__init__(*args,*kwargs)`
`        self.helper = FormHelper(self)`
`        self.helper.form.method='post'`
`        self.helper.add_input(Submit('Save','Submit'))`

I would like to get my data rendered to my signup page

{% extends 'base.html' %}
{% load crispy_forms_tags %}
{% block content %}
<div class="card" style = "width:25rem; margin:auto;">
    <div class="card-header" style="background-color:#248cd1; color:white;">
        Create your Order
      </div>
    <div class="card-body">
        <form method="POST" action="">
            {% csrf_token %}
            {% crispy form %}
        </form>
    </div>
</div>
{% endblock %}

How can I achieve that?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.