title: how can I get a valid object id of mongodb from a string?
body: <p>I want to make my mongodb OjectId to a field:</p>
  
  <pre><code>class ZhinengStats(Document):
      zhineng_id = ObjectIdField(db_field="_id", primary_key=True, required=True, help_text="job id")
  </code></pre>
  
  <p>but a valid ObjectId must be a 12-byte input of type 'str' or a 24-character hex string, so if I do this:</p>
  
  <pre><code>ZhinengStats.objects(zhineng_id="programmer").first()
  </code></pre>
  
  <p>I will get an error. I thought a hash is a good way:</p>
  
  <pre><code>hash("programmer") # 7354308922443094682
  </code></pre>
  
  <p>but as you can see, hash seems not ok.</p>
  
  <p>So how can I get a valid object id?</p>
  
  <hr>
  
  <p>UPDATE:</p>
  
  <p>the main problem is because this is field is a chinese, so something like this:<code>ObjectId('兼职'.decode("utf-8"))</code> can not work, so how can I make this support utf-8?</p>