title: What is the best way to write Django for user interaction using button which updates values in the model
body: <p>I am trying to write Django code for below:</p>
  <p>A user presses a button in the frontend. Multiple button options to decrement value by 10, 20, 30 etc.</p>
  <p>When the user presses the button, value for a Django model attribute in the backend will decrement accordingly. For example in the code below I set the intial value to 107. When the user presses the &quot;Subtract 10&quot; button in the html template, I want 10 subtracted from 107, so that the value then becomes 97. User is not entering any data.</p>
  <p>I unsuccessfully tried to use Django modelForm and &quot;POST&quot; and that did not work.</p>
  <p>Any suggestions appreciated.</p>
  <p>Below is the code I had that did not work.</p>
  <p>models.py</p>
  <pre><code>class Balance(models.Model):
      userBalance = models.DecimalField(max_digits=10, decimal_places=2, null=True)
  </code></pre>
  <p>forms.py</p>
  <pre><code>class BalanceForm(forms.ModelForm):
      class Meta:
          model = Balance
          fields = ['userBalance']
  </code></pre>
  <p>views.py</p>
  <pre><code>def balance(request):
      form = BalanceForm(initial={&quot;userBalance&quot;:107})
      if form.is_valid():
          if request.method == &quot;POST&quot; and &quot;form10&quot; in request.POST:
              formValue = form.cleaned_data.get('userBalance')
              form2 = formValue - 10
              return render(request, &quot;econlabs/balance.html&quot;, {'form2': form2})
      return render(request, &quot;econlabs/balance.html&quot;, {'form': form})
  </code></pre>