title: django return objects by selection value
body: <p>I have two models:</p>
  
  <pre><code>class Room(models.Model):
      room_name = models.CharField(max_length= 100)
      room_date = models.DateField(auto_now_add= True)
      room_value = models.PositiveSmallIntegerField(default=0)
  
  class RoomLog(models.Model):
      room = models.ForeignKey(Room)
      roomlog_date = models.DateField(auto_now_add= True)
      roomlog_value = models.PositiveSmallIntegerField(default=0)
  </code></pre>
  
  <p>each Room has got multiple related RoomLogs.
  for each Room every time Room.room_value is edited &amp; save a new RoomLog object is created.</p>
  
  <p>In Django templates I have a list of unique edits dates.
  I would like to click on a date and return for each Room a value that is maximum in a range 'less of equal' selection date.</p>
  
  <h2>How can I achieve it in django ?</h2>
  
  <p>The way I have done it so far:</p>
  
  <p><strong>in template I place:</strong> 
  search form:</p>
  
  <pre><code>&lt;form method='GET' action=''&gt;
  &lt;input type='text' name='q' placeholder='Select date'/&gt;
  &lt;input type='submit' value='Select'/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>and my view</strong>:</p>
  
  <pre><code>def main_view(request):
      query = request.GET.get("q")
  
      if query:
          queryset_list = RoomLog.objects.filter(created_date__lte = query)
          print queryset_list
  
      return render(request,'template.html', context)
  </code></pre>
  
  <p>so, in this way I can filter RoomLogs BUT I do not return max RoomLog for each Room at the moment and it is something I need to work out furhter.</p>