title: In Django how can I get a widget that accepts an ISO 8601 datetime string and works with a DateTimeField?
body: <p>I want to submit an ISO 8601 datetime string with a <a href="https://en.wikipedia.org/wiki/ISO_8601#Time_zone_designators" rel="nofollow">time zone designator</a> to a django form that I am writing. I want to use a standard <code>DateTimeField</code> for the datetime but have a widget that accepts such a datetime string. Is this possible, or am I confused about the relationship between Widgets and Fields? How do I do it?</p>
  
  <hr>
  
  <p>Parsing the string is easy, using <code>django.utils.datepase.parse_datetime</code>.</p>
  
  <p>I have tried writing a widget like so:</p>
  
  <pre><code>from django.forms import HiddenInput
  from django.utils.dateparse import parse_datetime
  
  class DateTimeInputForMachines(HiddenInput):
      def _format_value(self, value):
          out = super(DateTimeInputForMachines, self)._format_value(parse_datetime(value))
          return out
  </code></pre>
  
  <p>and using it in a <code>ModelForm</code> like so:</p>
  
  <pre><code>from mywidgets import DateTimeInputForMachines
  
  class MyForm(forms.ModelForm):
      class Meta:
          model = MyModel
          fields = ['start', 'thing']
  
          widgets = {
              'start': DateTimeInputForMachines()
          }
  </code></pre>
  
  <p>but the 'start' field fails validation with "Enter a valid date/time."</p>