title: Django auto increment to custom field
body: <p>I have <code>Product</code> db model, which should generate a <code>code</code> every time a new <code>Product</code> has been added.</p>
  <pre><code>class Product(models.Model): # Common
    code = models.CharField(_(&quot;Product Code&quot;), blank=True, max_length=100)
    #... Other Fields 
  
    def __str__(self):
        return self.code
  
    def custom_seq(pk, letters=4, digits=3):
       &quot;&quot;&quot;
       Generates a sequence when letters=4, digits=3 then, 'AAAA000', 'AAAA001', ..., 'ZZZZ999'
       Generates a sequence when letters=3, digits=4 then, 'AAA0000', 'AAA0001',..., 'ZZZ9999'
       &quot;&quot;&quot;
        alpha_list = [string.ascii_uppercase]*letters
        digit_list = [string.digits]*digits
        for i in itertools.product(*alpha_list):
          for j in itertools.product(*digit_list):
            yield &quot;&quot;.join(i + j)
  
    def save(self, *args, **kwargs):
      product_code = next(self.custom_seq())
      print(&quot;Code&quot;, product_code) #-- prints `AAAA000`
      if not self.code:
          self.code = product_code
      return super(Product, self).save(*args, **kwargs)
  </code></pre>
  <p>Everytime, I save a new <code>product</code> its generating only first sequence of my <code>custom_seq()</code> ie. <code>AAAA000</code>. but it should add new <code>code</code> to each newly generated instance such as 'AAAA001', 'AAAA002', 'AAAA003'...</p>