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

122
Views
Cómo leer el valor del botón de opción y usarlo desde FORM en el archivo view.py

Este es el código que está en el

 <fieldset class="form-group"> <div class="row"> <div class="col-sm-10"> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="transaction" id="deposit" value="deposit" checked="checked"> <label class="form-check-label" for="deposit"> Deposit </label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="transaction" id="deduction" value="deduction"> <label class="form-check-label" for="deduction"> Deduction </label> </div> </div> </div> </fieldset>

Estoy tratando de tomar la 'transacción' y usarla view.py y los cálculos serían algo como esto en view.py:

 def form_valid(self, form): if (#deposit is checked): newFinanceTotal = currentUserTotal + value else: newFinanceTotal = currentUserTotal - value form.save() return super().form_valid(form)

Y esto es lo que tengo en models.py:

 class Finance(models.Model): FINANCE_CHOICES = ( ('DP', 'Deposit'), ('DD', 'Deduction'), ) transaction = models.CharField(max_length=2, choices=FINANCE_CHOICES,)transaction = models.CharField(max_length=2, choices=FINANCE_CHOICES,)

formularios.py:

 class FinanceForm(forms.ModelForm): class Meta: model = Finance fields = ('entryName', 'entryDate', 'transaction', 'value')
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!