title: How to pass additional keyword arguments in a custom Field in Django Rest Framework?
body: <p>I'm using Django Rest Framework and want to create a custom Field to use in my serializers.</p>
  
  <pre><code>class PivotField(serializers.Field):
      def __init__(self, *args, **kwargs):
          self.key_attr   = kwargs.get('key_attr')
          self.value_attr = kwargs.get('value_attr')
          super(PivotField, self).__init__(*args, **kwargs)
  
      def to_representation(self, value):
          data = {}
          for model in value.all():
              # this is where I'd use the key_attr and value_attr
              data[model.type.name] = model.uri
          return data
  </code></pre>
  
  <p>I'd like to be able to pass additional arguments to the field like this.</p>
  
  <pre><code>resources = PivotField(key_attr='type.name', value_attr='uri')
  </code></pre>
  
  <p>However, I keep getting the following error.</p>
  
  <blockquote>
    <p>TypeError: <strong>init</strong>() got an unexpected keyword argument 'key_attr' </p>
  </blockquote>
  
  <p>Is there some way to register these as valid kwargs within the field?</p>