title: In Django filter posts in between two specific times
body: <p>I want to filter the posts which was added in between last 2 or 3 hours..
  i have already used timedelta etc but the filter keyword always want to get exact date, whereas</p>
  <pre><code>dt = timezone.now() - timedelta(hours=2)
  </code></pre>
  <p>never give exact datetime.. how can i achieve that??</p>
  <p><strong>models.py</strong></p>
  <pre><code>from django.db import models
  from datetime import datetime
  # Create your models here.
  class addPost(models.Model):
      date = models.DateTimeField(auto_now_add=True)
      postId = models.AutoField(primary_key=True)
      title = models.CharField(max_length=100)
      category = models.CharField(max_length=60)
      image = models.ImageField(upload_to=&quot;blog/images&quot;, default=&quot;&quot;)
      content = models.TextField(default=&quot;&quot;)
  </code></pre>
  <p><strong>views.py</strong></p>
  <pre><code>def index(request):
      dt = timezone.now() - timedelta(minutes=23)
      obj = addPost.objects.filter(date=dt)
      print(obj[0].date)
      return render(request, &quot;blog\home.html&quot;, {&quot;obj&quot;:obj})
  </code></pre>