title: How do I convert a django form input to python data?
body: <p>I have a widget that allows user to enter data for a model field. The data in the form can't be directly converted to Python - it requires some coercion. Where do I put this code? Is the widget responsible for translating its <code>post</code> data to a python value? The field itself?</p>
  
  <p>I thought that maybe <code>value_from_datadict()</code> would be correct, but now it looks like that serves a different purpose.</p>
  
  <p>(I'm using the form in the admin interface, if it makes any difference.)</p>
  
  <p><strong>Update</strong> @AndiDog: I'm incredulous that <code>to_python</code> is what I want. From the Django source:</p>
  
  <pre><code>135     def to_python(self, value):
  136         """
  137         Converts the input value into the expected Python data type, raising
  138         django.core.exceptions.ValidationError if the data can't be converted.
  139         Returns the converted value. Subclasses should override this.
  140         """
  141         return value
  </code></pre>
  
  <p>You're saying that this is called with <code>value</code> being the <code>POST</code> data from the form? I put in a print statement, and <code>value</code> is <code>None</code> when submitting the form, even though the input has data.</p>
  
  <p><strong>Update 2</strong>: Actually, it looks like <code>value_from_datadict</code> is the way to go. It has a dictionary from names of inputs to their values.</p>