title: How Can I Check if Date is Passed from Django Model
body: <p>I am really new in Django and I want to check if Date Stored in Model is passed. In fact, I am currently working on a ticketing app where users would have to purchase and activate ticket and I want to check if the Event Ticket Date is passed upon activation.</p>
  <p>My Models:</p>
  <pre><code>class Event(models.Model):
      event_name = models.CharField(max_length=100)
      date = models.DateField(auto_now_add=False, auto_now=False, null=False)
      event_venue = models.CharField(max_length=200)
      event_logo = models.ImageField(default='avatar.jpg', blank=False, null=False, upload_to ='profile_images')
      added_date = models.DateTimeField(auto_now_add=True)
  
      def __str__(self):
          return f&quot;{self.event_name}&quot;
  
      #Prepare the url path for the Model
      def get_absolute_url(self):
          return reverse(&quot;event_detail&quot;, args=[str(self.id)])
  
  class Ticket(models.Model):
      event = models.ForeignKey(Event, on_delete=models.CASCADE)
      price = models.PositiveIntegerField()
      category = models.CharField(max_length=100, choices=PASS, default=None, blank=False, null=False)
      added_date = models.DateField(auto_now_add=True)
  
      def __str__(self):
          return f&quot;{self.event} &quot;
  
      #Prepare the url path for the Model
      def get_absolute_url(self):
          return reverse(&quot;ticket-detail&quot;, args=[str(self.id)])
  
      def generate_pin():
          return ''.join(str(randint(0, 9)) for _ in range(6))
  
  class Pin(models.Model):
      ticket = models.ForeignKey(Ticket, on_delete=models.CASCADE)
      value = models.CharField(max_length=6, default=generate_pin, blank=True)
      added = models.DateTimeField(auto_now_add=True,  blank=False)
      reference = models.UUIDField(primary_key = True, editable = False, default=uuid.uuid4)
      status = models.CharField(max_length=30, default='Not Activated')
  
      #Save Reference Number
      def save(self, *args, **kwargs):
          self.reference == str(uuid.uuid4())
          super().save(*args, **kwargs) 
  
      def __unicode__(self):
          return self.ticket
  
     class Meta:
          unique_together = [&quot;ticket&quot;, &quot;value&quot;]
  
    def __str__(self):
         return f&quot;{self.ticket}&quot;
  
    def get_absolute_url(self):
         return reverse(&quot;pin-detail&quot;, args=[str(self.id)])
  </code></pre>
  <p>My Views for PIN Activation</p>
  <pre><code>def pin_activation(request):
  if request.method == &quot;POST&quot;:
      
      #Create new form with name form
      form = PinActivationForm(request.POST)
  
      #Check if the the form has valid data in it
      if form.is_valid():
  
          #Check the status of the user Pin with the one in the Database
          check_pin_status = Pin.objects.get(value=form['pin'].value(), status='Not Activated')
  
          #Check if the PIN is correct and NOT ACTIVATED
          if check_pin_status:
       
              #Get the Pin, Ticket, Event Date
              event_date = check_pin_status.ticket.event.date
              
              current_date = datetime.now()
  
              if event_date &gt; current_date:
                  messages.error(request, 'Event Has Passed')
                  return redirect('pages-index')
              else:
                   #Update the User Pin with a new status of Activated
                  Pin.objects.filter(value=form['pin'].value()).update(status='Validated')
                  #Message the User
                  messages.success(request, 'Pin Validated Successfully')
                  #Redirect the user to register for seat
                  return redirect('register-guest')
  
  
  
             
          #Check filter the DB where the PIN status is Validated
          elif Pin.objects.filter(value=form['pin'].value(), status=&quot;Validated&quot;):
              messages.error(request, 'Pin Already Validated. Register for Seat')
              return redirect('register-guest')
          #Check Filter PIN in DB where Status is Activated
          elif  Pin.objects.filter(value=form['pin'].value(), status=&quot;Activated&quot;):
              messages.error(request, &quot;Pin Already Activated, Login.&quot;)
              return redirect('user-login')
              
                 
      else:
          messages.error(request, 'Something Went Wrong. Try again')
  else:
      form = PinActivationForm()
  context = {
      'form':form,
  }
  return render(request, 'user/pin_activation.html', context)
  </code></pre>
  <p>Someone should help me on the best way of solving this problem because with my code for checking of date I am having <strong>can't compare datetime.datetime to datetime.date</strong>.</p>