[Answer]-Django- Using Parameters To Display Entry

1👍

Use the filter() method of a model manager with a combination of __lte/__gte lookups:

def comments(request):
    value = float(request.GET['value'])
    return render(request, 'comments.html',
                 {'comments': comments.objects.filter(min__lte=value,
                                                      max__gte=value)})

And then in the comments.html:

{% for comment in comments %}
    <div>{{ comment.comment }}</div>
{% endfor %}

Leave a comment