class ReceiptView(FilterView):
model = Receipt
template_name = 'receipts/receipts.html'
context_object_name = 'receipts'
filterset_class = ReceiptsFilter
filter_backends = (filters.DjangoFilterBackend,)
error_message = gettext_lazy('У вас нет прав на просмотр данной страницы! '
'Авторизуйтесь!')
login_url = 'login'
class ReceiptsFilter(django_filters.FilterSet):
names_seller = Receipt.objects.values_list('name_seller', 'name_seller').distinct()
name_seller = filters.ChoiceFilter(label='Seller', choices=names_seller)
class Meta:
model = Receipt
fields = ('name_seller', )
{% for receipt in object_list %}
{% endfor %}