title: how to store count value in python(django)?
body: <p>I am trying to implement an upload limit functionality.
  I found that Everything is working as expected except the <strong>count</strong> value.</p>
  <p>Please find the below views.py code.</p>
  <pre><code>def CTA_upload(request):
      i = 1
      count = [0,]
      print('Counter value at starting::::::::: :', len(count))
      allcts = CTS.objects.all()
      try:
          if len(count) &lt;= 14:
              if request.method == 'POST':
                  movie_resource = CTAResource()
                  print('movie_resource', movie_resource)
                  dataset = Dataset()
                  new_movie = request.FILES['file']
                  if not new_movie.name.endswith('xls'):
                      messages.info(request, 'Sorry Wrong File Format.Please Upload valid format')
                      return render(request, 'app/uploadctsa.html')
                  messages.info(request, 'stage1 fired:Processing  file type is Okay :)...')
                  imported_data = dataset.load(new_movie.read(), format='xls')
                  print('abcdefghijk:', type(imported_data))
                  messages.info(request, 'Stage2 fired:*** Now checking data inside imported data :)')
                  for data in imported_data:
                      value = CTA(
                          data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8],
                      )
                      print('Value 1 ::::', value)
                      print('Final Count After entering &lt; = 15:', len(count))
                      messages.info(request, 'Stage3 fired:*** Now entering to check count &lt;= :)')
                      i = i + 1
                      count.append(i)
                      print('Count After Appending Value:',count)
                      value.save()
          else:
              print('Final ***else Count when &gt; = is equal to 15:', len(count))
              messages.info(request, 'Sorry you are uploading more than 15 records so records')
              print('Final count jo hai variable me store:', count)
              messages.info(request,
                            'Sleeping For 10 sec and then it will clear count value. so you can upload extra data after 10 sec..')
              time.sleep(10)
              count.clear()
              print('Counter value after Clearing::::::::: :', len(count))
              messages.info(request,
                            'Sorry You have uploaded more data than specified limit./Same Email ID has been observed more than once.Except that other records has been added../nPlease Make sure Email field should be unique.')
              
      except:
          messages.info(request,'Sorry You have uploaded more data than specified limit./Same Email ID has been observed more than once.Except that other records has been added../nPlease Make sure Email field should be unique.')
          print(&quot;Problem hai kuch to&quot;)
  
      return render(request,'app/uploadctsa.html')
  </code></pre>
  <p>Problem: Here I am checking count so if it is more than 14 records it will not save in the database.
  and I want to store the count value so that if within 600 sec if anyone again uploading any records it will check the count value and then process(because after 600-sec I am clearing the count value) but here count value is not getting saved for every new upload within 600sec also it is starting from the beginning.</p>
  <p>Any way to store the count value so that if anyone is uploading any records it will check what is the last stored value in the count variable and then process.</p>
  <p>below is the terminal output I am getting:</p>
  <pre><code>Counter value at starting::::::::: : 1
  [07/Feb/2021 15:40:51] &quot;GET /cts_upload/ HTTP/1.1&quot; 200 4114
  Counter value at starting::::::::: : 1
  movie_resource &lt;apple.resources.CTSResource object at 0x107d11dd0&gt;
  abcdefghijk: &lt;class 'tablib.core.Dataset'&gt;
  Value 1 :::: CTS object (2320182568.0)
  Final Count After entering &lt; = 15: 1
  Count After Appending Value: [0, 2]
  Value 1 :::: CTS object (2319852359.0)
  Final Count After entering &lt; = 15: 2
  Count After Appending Value: [0, 2, 3]
  Value 1 :::: CTS object (2304621214.0)
  Final Count After entering &lt; = 15: 3
  Count After Appending Value: [0, 2, 3, 4]
  Value 1 :::: CTS object (2304611412.0)
  Final Count After entering &lt; = 15: 4
  Count After Appending Value: [0, 2, 3, 4, 5]
  Value 1 :::: CTS object (2304447326.0)
  Final Count After entering &lt; = 15: 5
  Count After Appending Value: [0, 2, 3, 4, 5, 6]
  Value 1 :::: CTS object (2304389748.0)
  Final Count After entering &lt; = 15: 6
  Count After Appending Value: [0, 2, 3, 4, 5, 6, 7]
  Value 1 :::: CTS object (2304386109.0)
  Final Count After entering &lt; = 15: 7
  Count After Appending Value: [0, 2, 3, 4, 5, 6, 7, 8]
  Value 1 :::: CTS object (2304383202.0)
  Final Count After entering &lt; = 15: 8
  Count After Appending Value: [0, 2, 3, 4, 5, 6, 7, 8, 9]
  Value 1 :::: CTS object (2304185694.0)
  Final Count After entering &lt; = 15: 9
  Count After Appending Value: [0, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  Value 1 :::: CTS object (2304185187.0)
  Final Count After entering &lt; = 15: 10
  Count After Appending Value: [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
  Value 1 :::: CTS object (2303072735.0)
  Final Count After entering &lt; = 15: 11
  Count After Appending Value: [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
  Value 1 :::: CTS object (2303072734.0)
  Final Count After entering &lt; = 15: 12
  Count After Appending Value: [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
  Value 1 :::: CTS object (2303072717.0)
  Final Count After entering &lt; = 15: 13
  Count After Appending Value: [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
  [07/Feb/2021 15:41:07] &quot;POST /cts_upload/ HTTP/1.1&quot; 200 5254
  </code></pre>