I have two issue
-
I just want to exclude the items which is in db, other item which is not in ordeerRequest table will be display, but after my query it show nothing
-
In template when i select any category it just show the last category which i added. After select any category it should show the that category but it show last added category by default
View.py
def get(self, request, *args, **kwargs): status = self.request.GET.get('action') == 'accept' orderCheck = Order.objects.exclude( orderrequest__order_status__in=OrderRequest.objects.filter(order_status=status) ) args = {'orderCheck': orderCheck} return render(request, self.template_name, args)
category show
def get(self, request, *args, **kwargs): categories = Category.objects.all() categoryId = self.request.GET.get('SelectCategory') products = Product.objects.filter(category_id=categoryId) args = {'categories': categories, 'products': products, 'selectedCategory': categoryId} return render(request, self.template_name, args)
Template
<label> <select name="SelectCategory" > <option disabled="disabled" > Select Category</option> </select> </label>
https://stackoverflow.com/questions/67025524/how-can-exclude-the-item-which-is-in-db-django April 10, 2021 at 01:13AM
没有评论:
发表评论