I am trying to search and list in between two dates from database ,,but do not know how to do it?? the
models.py
...
class ProductsTbl(models.Model):
    created = models.DateTimeField(editable=False)
...
views.py
def search(request):
    error = False
    if 'q1' and 'q2'in request.GET:
        q = request.GET['q1','q2']
        if not q:
            error = True
        else:
            books = ProductsTbl.objects.filter(created__range=q)
            return render(request, 'search_results.html',
                {'books': books, 'query': q})
    return render(request, 'search_form.html', {'error': error})
I have look up stackoverflow here but do not understand how to do it
shoud I add one more DateTimeField in models.py to help search??
actually I can do it in python manage.py shell, but how can I make it works on the web??

my
search_form.html
<form action="" method="get">
<table style="width:30%">
<tr>
<td><input type="text"  class="datepicker" name="q1"> </td>
<td style="width:5%"> between </td>
<td><input type="text"  class="datepicker" name="q2"></td>
<br>
<td><input type="submit" value="Search"></td>
</tr>
</table>
</form>
the
search_results.html
{% if books %}
<p>Found {{ books|length }} product{{ books|pluralize }}.</p>
<ul>
{% for book in books %}
<li>{{ book.created }}</li>
<h2><a href="{% url 'thing_detail' slug=book.slug %}">{{ book.name }}</a></h2>
{% endfor %}
</ul>
{% else %}
<p>No products matched your search criteria.</p>
{% endif %}
if only filter for one date it is ok for me to use this
views.py
def publish(request):
    error = False
    if 'q' in request.GET:
        q = request.GET['q']
        if not q:
            error = True
        else:
            books = ProductsTbl.objects.filter(release__icontains=q)
            return render(request, 'publish_results.html',
                {'books': books, 'query': q})
    return render(request, 'publish_form.html', {'error': error})
however ,,,when comes between two dates range,,,I do not know how to do it

 
     
     
    