title: how to write a method in order to change database directly in Django model
body: <p>I made a Product class in Django models like :</p>
  
  <pre><code>class Product(models.Model):
      title = models.CharField(max_length=255, unique = True)
      description = models.TextField()
      image_url = models.URLField(verify_exists=True, max_length=200, blank = True, null = True)
      quantity = models.PositiveSmallIntegerField(default=0)
  </code></pre>
  
  <p>And i want to add a sell() method inside this class. well i did like:</p>
  
  <pre><code>def sell(self):
      result = self.quantity - 1
      return result
  </code></pre>
  
  <p>I want to change the value in database when just execute P.sell(). </p>
  
  <p>when i run it in the shell like this</p>
  
  <pre><code> &gt;&gt;p = Product(title = 'title', description = 'des', quantity = 10)
   &gt;&gt;p.save()
   &gt;&gt;p.sell()
  9    # it shown 9, but the database not changed still 10
  </code></pre>
  
  <h1>but if i continue to do like this</h1>
  
  <pre><code>&gt;&gt; p.quantity = p.sell()
  &gt;&gt; p.save()
  </code></pre>
  
  <h1>it can change the quantity to 9</h1>
  
  <p>but how can i just change the value when i just type p.sell() ?
  how could i edit it in models? </p>