1👍
✅
Try,
class YourView(ListView):
model = product
def get_queryset(self):
queryset = super(YourView, self).get_queryset()
#your condition here.
return queryset.filter(pk__in=[1,2,3])
1👍
Just split it into 2 lines:
model = Product
and
queryset = Product.objects.filter(pk__in=[1,2,3,4,5])
It will work.
- [Answered ]-Django and formsets
- [Answered ]-Django websocker error: AttributeError: 'super' object has no attribute 'init'
- [Answered ]-Django doesn't use pyodbc as python does
- [Answered ]-Django 1054, "Unknown column 'emp_id' in 'field list"
- [Answered ]-Custom DRF list function not returning some of the dict key/value pairs
- [Answered ]-How to use a file chooser in Django?
- [Answered ]-Update / Save model date value directly from template?
Source:stackexchange.com