How to avoid whitespace %20 in menufilter for a django app

Hello,

I’m working on an ecommerce website with categories and sub-categories. The sub-categories with not space e.g Sneakers work with the menufilter but sub-catgeories with space e.g Blouse and T-shirt returns no product found page even when there are products under the category.

Pls, help me.

Thanks

def MenuFilter(request, cat):
	print(cat.split(',')[0])
	prod = []

	
	for p in [i for i in Product.objects.filter(subcategory=cat) #if str(i.category).lower() == querys.split(',')[0].lower() and str(i.subcategory).lower()==querys.split(',')[1].lower()
		   ]:
		prod.append([p,[item for item in ProductSize.objects.filter(product=p)]])