title: Django Serializer - replacing a key with data from the database
body: <p>I've got a Django model as such:</p>
  
  <pre><code>class Document(models.Model):
      identifier = models.CharField(max_length=255)
      user = models.ForeignKey(User)
      document = models.TextField()
  </code></pre>
  
  <p>And I want to output JSON that looks like this (this is per result):</p>
  
  <pre><code>{(identifier): (document)}, etc
  </code></pre>
  
  <p>I am trying to figure out if there's a way to do this using the serializers.</p>
  
  <p>So far I've got this:</p>
  
  <pre><code>class DocumentSerializer(serializers.ModelSerializer):
      identifier = serializers.SerializerMethodField('getidentifier')
      class Meta:
          model = Document
          fields = ('identifier', 'document')
  
      def getidentifier(self, obj):
          return obj.getidentifier
  </code></pre>
  
  <p>But I don't understand exactly what's going on or how to get/organize the values I want.</p>
  
  <p>How do I take two values from the database, and turn them into a key:value pair, per result?</p>