title: JSON to model a class using Django
body: <p>I'm trying to get a JSON object like:</p>
  
  <pre><code>{
      "username": "clelio",
      "name": "Clelio de Paula",
  }
  </code></pre>
  
  <p>and transform it in:</p>
  
  <pre><code>  class User(models.Model):
  
       name = models.CharField(max_length=30)
       username = models.CharField(max_length=20)
  
       def jsonToClass(s):
  
         aux = json.dumps(s, self)
  
         self.name = aux['name']
         self.id = aux['id']
  </code></pre>
  
  <p>So I tried to use the <code>simplejson</code> and one method called <code>jsonToClass()</code>:</p>
  
  <pre><code>  &gt;&gt;&gt; import simplejson as json
    &gt;&gt;&gt; u1 = User()
    &gt;&gt;&gt; u1.jsonToClass(face)
    &gt;&gt;&gt; u1.save()
  </code></pre>
  
  <p>This doesn't work. What is the easiest method to do what I want?</p>