title: FloatField __init__ got an unexpected keyword argument 'max_value'
body: <p>I recently asked <a href="https://stackoverflow.com/questions/50951852/why-does-cloning-this-subclass-of-floatfield-with-added-validators-throw-an-ex/50951987#50951987">this question</a> and solved my problem as originally stated. The following code works:</p>
  
  <pre><code>class FloatRangeField (FloatField):
      """A FloatField constrained to a given range."""
  
      def __init__ (self, minimum, maximum, **kwargs):
  
          minmax = [MinValueValidator (minimum), MaxValueValidator (maximum)]
  
          self.minimum = minimum
          self.maximum = maximum
  
          kwargs ['validators'] = minmax
  
          FloatField.__init__ (self, **kwargs)
  
      def deconstruct (self):
          name, path, args, kwargs = super () .deconstruct ()
  
          kwargs ['minimum'] = self.minimum
          kwargs ['maximum'] = self.maximum
  
          del kwargs ['validators']
  
          return name, path, args, kwargs
  
  
  
  class AffinityField (FloatRangeField):
      """An affinity is a float from -1 (hate) to +1 (love)."""
  
      def __init__ (self, **kwargs):
          FloatRangeField.__init__ (self, -1.0, 1.0, **kwargs)
  
      def deconstruct (self):
          name, path, args, kwargs = super () .deconstruct ()
  
          del kwargs ['minimum']
          del kwargs ['maximum']
  
          return name, path, args, kwargs
  </code></pre>
  
  <p>However, I don't believe this is quite complete. I am new to Django, but my understanding is that adding validators constrains the data that the model is willing to save, but separately from this, as <a href="https://stackoverflow.com/a/10539731/458742">this answer indicates</a>, there is validation at the form level.</p>
  
  <blockquote>
    <p>If you need constraint on form level you can pass min_value and max_value to form field:</p>
  
  <pre><code>myfloat = forms.FloatField(min_value=0.0, max_value=1.0)
  </code></pre>
  </blockquote>
  
  <p>I don't have any visible forms yet (just starting to learn!) so I don't know if it is necessary to do this separately, but from the sounds of it I <em>do</em> have to pass <code>min_value</code> and <code>max_value</code> as well as the validator objects. Here is my attempt:</p>
  
  <pre><code>class FloatRangeField (FloatField):
      """A FloatField constrained to a given range."""
  
      def __init__ (self, minimum, maximum, **kwargs):
  
          minmax = [MinValueValidator (minimum), MaxValueValidator (maximum)]
  
          self.minimum = minimum
          self.maximum = maximum
  
          # Validators for the model
          kwargs ['validators'] = minmax
  
          # Arguments for the form validation
          kwargs ['min_value']  = minimum
          kwargs ['max_value']  = maximum
  
          FloatField.__init__ (self, **kwargs)
  
      def deconstruct (self):
          name, path, args, kwargs = super () .deconstruct ()
  
          kwargs ['minimum'] = self.minimum
          kwargs ['maximum'] = self.maximum
  
          del kwargs ['validators']
          del kwargs ['min_value']
          del kwargs ['max_value']
  
          return name, path, args, kwargs
  </code></pre>
  
  <p>This throws an exception:</p>
  
  <pre><code>    FloatField.__init__ (self, **kwargs)
  TypeError: __init__() got an unexpected keyword argument 'min_value'
  </code></pre>
  
  <p>But <a href="https://docs.djangoproject.com/en/dev/ref/forms/fields/#floatfield" rel="nofollow noreferrer">according to the documentation</a>, the <code>min_value</code> argument <em>is</em> expected, so I don't know what this error really means.</p>
  
  <p>I thought I understood the principle of field deconstructors (delete from <code>kwargs</code> those things which you don't need as inputs when you define them in the child class's <code>__init__</code>) but perhaps not.</p>
  
  <p>What's wrong with how I'm using <code>min_value</code> and <code>max_value</code>?</p>