title: how to count the number of downloads of a file with django
body: <p>I would like to count the number of file downloads that I put at the disposal of my user, but I can not. My site is in some ways an application library that I design, and that I can share.</p>
  
  <p>I use that for Django 2, so I tried to use a middleware, but without finding what he had to do. I can count the number of pages displayed, so I told myself that I could only filter the page of the download, but I realize that it starts without changing pages.</p>
  
  <p>Here are the models used:</p>
  
  <pre class="lang-py prettyprint-override"><code>class Program (models.Model):
      name = models.CharField(max_length = 100, default = "Nom du Programme")
      description = models.TextField(default = "Ceci est la description d'un programme")
      created_at = models.DateTimeField (auto_now = False, auto_now_add=True)
      updated_at = models.DateTimeField (auto_now = True, auto_now_add=False)
      image = models.ImageField (upload_to = 'images', null=True)
      download_file = models.FileField (upload_to = 'executables', null=True)
      slug = models.SlugField (default="programme_{}".format(id))
      youtube_code = models.TextField(null=True)
  
      stat_ref = models.OneToOneField('Stat', on_delete = models.CASCADE, null=True)
      operating_system_ref = models.OneToOneField('OperatingSystem', on_delete = models.CASCADE, null=True) 
  
      def __str__(self):
          return self.name
  </code></pre>
  
  <p>Thanks for the help!</p>