title: Django: How to increment a counter stored in models.py / Database
body: <p>I have created a small counter model <code>class Counter</code> to store the amount of times a small survey application has been completed. </p>
  
  <p>I want to increment <code>SurveyWizardOneCounter</code> in my models.py from my <code>def done()</code> method in my views.py</p>
  
  <p>Can anyone tell me how to do this?</p>
  
  <p>Previously I was using Global variables for my counter which I have found out do not work properly with a web app. I am trying to learn how to create and store a counter in my DB. Any help is appreciated. </p>
  
  <p><strong>models.py</strong></p>
  
  <pre><code>class Counter(models.Model):                
      SurveyWizardOneCounter = models.SmallIntegerField()
      TotalMaxCounter = models.SmallIntegerField() 
  </code></pre>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>from survey.models import Counter
  
  def done(self, form_list, **kwargs):
  
      Counter.SurveyWizardOneCounter += 1  # This is where I am trying to increment the counter
  
      logger.debug('\n\n SurveyWizardOneCounter = %s', SurveyWizardOneCounter)
  
      for form in form_list:
          form.save()
  
      return render(self.request, 'Return_to_AMT.html', {
          'form_data': [form.cleaned_data for form in form_list],            
      })  
  </code></pre>