1👍
✅
You filter with:
class All_Vendor(TemplateView):
template_name = 'purchase/allVendor.html'
def get(self, request, *args, **kwargs):
categories = categoryModel.objects.all()
categoryId = self.request.GET.get('SelectCategory')
vendors = Vendor.objects.filter(
vendorcategory__category_id=categoryId
)
args = {'categories': categories, 'selectedCategory': categoryId, 'vendors': vendors}
return render(request, self.template_name, args)
vendorselect
makes not much sense, since that is a collection of VendorCategory
s, not Vendor
s.
Source:stackexchange.com