K
K
KatyaBychko2022-04-04 15:51:45
Django
KatyaBychko, 2022-04-04 15:51:45

How to filter date by range (Django_filters)?

It is necessary to make a field for filtering the date within the range that the user sets. Please let me know which one is easier.

class TYFilter(django_filters.FilterSet):

    class Meta:
        model = Technical_Y
        fields = ['number_ty', 'date_ty', 'fullname']

def generalTY(request, number_z=None):
    ty = Technical_Y.objects.filter(group=request_group)
    filtered_ty = TYFilter(request.GET, queryset=Technical_Y.objects.all())

    return render(request, 'ty.html', {'filtered_ty': filtered_ty, 'ty':ty})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2022-04-04
@KatyaBychko

https://django-filter.readthedocs.io/en/stable/ref...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question