title: Django : Timestamp string custom field
body: <p>I'm trying to create a custom timestamp field.</p>
  
  <pre><code>class TimestampKey(models.CharField):
      __metaclass__ = models.SubfieldBase
  
      def __init__(self, *args, **kwargs):
          import time
  
          kwargs['unique'] = True
          kwargs['max_length'] = 20
          kwargs['auto_created'] = True
          kwargs['editable']=False
          super(TimestampKey, self).__init__(*args, **kwargs)
  
      def to_python(self, value) :
          return value
  
      def get_db_prep_value(self, value) :
          try:
              import time
              t = time.localtime()
              value = reduce(lambda a,b:str(a)+str(b),t)
          except ValueError:
              value = {}
  
          return value
  
  
  class Table1(models.Model):
         f = TimestampKey(primary_key=True)
         n = ....
  </code></pre>
  
  <p>It stores the value with appropriate timestamp in the db. But it doesnt populate the field 'f' in the object.</p>
  
  <p>Eg:</p>
  
  <pre><code>t1 = Table1(n="some value")
  t1.f -&gt; blank
  
  t1.save()
  
  t1.f -&gt; blank. 
  </code></pre>
  
  <p>This is the problem. Am I missing something so that it doesnt populate the filed?
  Please shed some light on this.</p>
  
  <p>Thanks.</p>