title: How to use opencv in Django?
body: <p>I'm a beginner in Django and I want to convert my image to grayscale before to upload it with opencv.
  This is what I've tried to do but it doesn't work</p>
  
  <p>`</p>
  
  <pre><code>from __future__ import unicode_literals
  from django.db import models
  import cv2
  
  class Personne(models.Model):
      nom = models.CharField(max_length=50, unique=True, help_text="Le nom est unique")
      description = models.TextField(blank=True)
  
      def __unicode__(self):
          return self.nom[:50]
  
  def traitement(filename):
      img = cv2.imread(filename, 0)
      cv2.imwrite(filename, img)
  
  
  class Visage(models.Model):
  
      personne = models.ForeignKey(Personne)
  
      def generate_filename(self, filename):
          return "Images/%s/%s" % (self.personne.nom, filename)
  
      traitement
      image = models.ImageField(blank=False, upload_to=generate_filename)
      ajoute_le = models.DateTimeField(auto_now_add=True)
  
      def __unicode__(self):
          return self.image.path`
  </code></pre>