title: Django Models: Generate field content from other fields in model instance
body: <p>As an example, say I'm logging inventory items, and I need a unique identifier (that is also meaningful when read by itself) for each item.</p>
  
  <p> The following shows the model I am trying </p>
  
  <pre><code>class InventoryItem(models.Model):
      item_name = models.TextField(max_length = 100)
      item_manufacturer = models.TextField(max_length = 20)
      item_product_num = models.TextField(max_length = 25)
      item_lot = models.TextField(max_length = 25)
      item_received_on = models.DateTimeField(auto_now_add = True)
      item_price = models.DecimalField()
      item_quantity = models.DecimalField()
      item_special_instructions = models.TextField(default = "NA", max_length = 200)
      item_reinspection_date = models.DateField()
  
      def makeUniqueID(self):
          unique_str = self.item_manufacturer + self.item_product_num + self.item_lot + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
          return unique_str
      item_uniqueID = models.TextField(max_length = 50, default = self.makeUniqueID())
  </code></pre>
  
  <p>The above code errors <code>NameError: name 'self' is not defined</code>, and I suspect this is not the correct way to do this.
  Any help is greatly appreciated!</p>
  
  <p>The database I'm using is SQLite if that changes anything</p>