title: Django 1 Models - DateTimeField()
body: <p>I am very new to Django and programming in general and I am facing a challenge I have not seen before. I a looking for a bit of help with DateTimeField().</p>
  
  <p>As a learning project, I am setting up a simple travel app. I would like users to be able to add trips, descriptions, etc. So far, so good. </p>
  
  <p>I would like to add two DateTimeFields to my trips model. The start_date entered must be a date in the future (from the time they are using the app), while the end_date will have to be after the start_date (natch). How do I program this into my models?</p>
  
  <p>Here is my current code for my Trip class:</p>
  
  <pre><code>class Trip(models.Model):
      destination = models.CharField(max_length=55)
      description = models.TextField()
      start_date = models.DateTimeField(??)
      end_date = models.DateTimeField(??)
  
      travellers = models.ManyToManyField(User, related_name="trips")
  
      planned_by = models.ForeignKey(User, on_delete=models.CASCADE, related_name="trips_added")
  
      created_at = models.DateTimeField(auto_now_add=True)
      updated_at = models.DateTimeField(auto_now=True)
  </code></pre>
  
  <p>Thank you.</p>
  
  <p><strong>Update</strong></p>
  
  <p>Thanks to you guys I am getting closer. However, I think there is a wrinkle or two in DateField (I don't actually need DateTimeField) that I am missing. Here is my Trip table in models:</p>
  
  <pre><code>class Trip(models.Model):
      destination = models.CharField(max_length=55)
      description = models.TextField()
      start_date = models.DateField(null=True)
      end_date = models.DateField(null=True)
  
      travelers = models.ManyToManyField(User, related_name="trips")
  
      planned_by = models.ForeignKey(User, on_delete=models.CASCADE, related_name="trips_added")
  
      created_at = models.DateTimeField(auto_now_add=True)
      updated_at = models.DateTimeField(auto_now=True)
  
      objects = TripManager()
  </code></pre>
  
  <p>Also in models, under my TripManager, I have the following validation method:</p>
  
  <pre><code>def trip_validation(self, postData):
  
          errors = {}
  
          if len(postData['destination']) &lt; 1:
              errors['destination'] = 'You must enter trip destination.'
  
          if len(postData['description']) &lt; 1:
              errors['description'] = 'You must enter trip description.'
  
          if len(postData['start_date']) &lt; 1:
              errors['start_date'] = 'Please enter a start date for your trip.'
          elif not postData['start_date'] &gt; timezone.now():
              errors['start_date'] = 'Your trip start date must be in the future.'
  
          if len(postData['end_date']) &lt; 1:
              errors['end_date'] = 'Please enter an end date for your trip.'
          elif not self.end_date &gt; self.start_date:
              errors['end_date'] = 'Trip end date must be after start date.'
  
          return errors
  </code></pre>
  
  <p>In views, I call the trip_validation method and sent the errors to the template via a context dict. </p>
  
  <p>All of the validation methods work save <code>elif not postData['start_date'] &gt; timezone.now():</code> and <code>elif not self.end_date &gt; self.start_date:</code>.</p>
  
  <p>I get the following error: <code>TypeError at /trips/add/
  can't compare datetime.datetime to unicode</code>.</p>
  
  <p>This leads me to believe that I am not using the built-in DateField function properly somewhere along the line.</p>
  
  <p>Thank you.</p>