title: Django/ Python set min/ max date values on DateTimeField
body: <p>I have a Django form, with a date field displayed on it, which has a data type of <code>mDateField</code> (a custom class that extends <code>forms.DateField</code>). It is defined in forms.py with:</p>
  
  <pre><code>class mDateField(forms.DateField):
      def __init__(self, *args, **kwargs):
          kwargs.setdefault('input_formats', DATE_INPUT_FORMATS)
          super(mDateField, self).__init__(*args, **kwargs)
  </code></pre>
  
  <p>I now want to set a 'minimum' &amp; 'maximum' possible value for that date field (i.e. a date a certain length of time either in the past or in the future relevant to today's date that this value can be set to).</p>
  
  <p>I came across this answer on SO: <a href="https://stackoverflow.com/questions/5375373/jquery-datetime-picker-set-mindate-dynamic">jquery datetime picker set minDate dynamic</a> and tried following what it says, by writing the line:</p>
  
  <pre><code>    presentation_date = mDateTimeField(required=False, widget=forms.DateTimeInput(format='%d/%m/%Y %H:%M', attrs=({'class':'datetimepicker presentation_date', 'name':'presentation_date2'})))
      presentation_date.options.maxDate = $( ".selector" ).datepicker( "option", "maxDate", new Date(2014, 1 - 1, 1));
  </code></pre>
  
  <p>but when I do, I get a syntax error in the console, which points to the <code>$</code>, and says:</p>
  
  <blockquote>
    <p>SyntaxError: invalid syntax</p>
  </blockquote>
  
  <p>What is wrong with what I'm doing here? How can I specify what the earliest/ latest date to be shown in the <code>datepicker</code> should be?</p>
  
  <p><strong>Edit</strong> In the jQuery file where <code>datetimepicker</code> is defined (jquery.datetimepicker.full.js), there are the following lines:</p>
  
  <pre><code>if (options.minDate &amp;&amp; /^[\+\-](.*)$/.test(options.minDate)) {
      options.minDate = dateHelper.formatDate(_xdsoft_datetime.strToDateTime(options.minDate), options.formatDate);
  }
  
  if (options.maxDate &amp;&amp;  /^[\+\-](.*)$/.test(options.maxDate)) {
      options.maxDate = dateHelper.formatDate(_xdsoft_datetime.strToDateTime(options.maxDate), options.formatDate);
  }
  </code></pre>
  
  <p>But I don't see how these are setting the values to any actual dates...?</p>