I am trying to filter a queryset by a list I am getting unicode data into format of 1,4,5,6 by
category = request.GET.getlist(category')
print type(category)data = Leads.objects.filter(item_required__id= category )
then i am getting a error
invalid literal for int() with base 10: '1,4'
So how can i fix this.
Traceback:
File "/home/cp/Documents/envMyShopUp/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/cp/Documents/envMyShopUp/local/lib/python2.7/site-packages/django/views/decorators/csrf.py" in wrapped_view58. return view_func(*args, **kwargs)
File "/home/cp/Documents/myshopup/markatix/customapi/vendors.py" in CustomerRequirements365. cust_leads = CustomerLeads.objects.filter(item_required__id__in= category ).values('customer_name','budget','event','posting_date','quantity','other','fb_id','image','title').order_by('-posting_date')
File "/home/cp/Documents/envMyShopUp/local/lib/python2.7/site-packages/django/db/models/manager.py" in manager_method127. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/cp/Documents/envMyShopUp/local/lib/python2.7/site-packages/django/db/models/query.py" in filter679. return self._filter_or_exclude(False, *args, **kwargs)
File "/home/cp/Documents/envMyShopUp/local/lib/python2.7/site-packages/django/db/models/query.py" in _filter_or_exclude697. clone.query.add_q(Q(*args, **kwargs))
File "/home/cp/Documents/envMyShopUp/local/lib/python2.7/site-packages/django/db/models/sql/query.py" in add_q1310. clause, require_inner = self._add_q(where_part, self.used_aliases)
File "/home/cp/Documents/envMyShopUp/local/lib/python2.7/site-packages/django/db/models/sql/query.py" in _add_q1338. allow_joins=allow_joins, split_subq=split_subq,
File "/home/cp/Documents/envMyShopUp/local/lib/python2.7/site-packages/django/db/models/sql/query.py" in build_filter1209. condition = self.build_lookup(lookups, col, value)
File "/home/cp/Documents/envMyShopUp/local/lib/python2.7/site-packages/django/db/models/sql/query.py" in build_lookup1102. return final_lookup(lhs, rhs)
File "/home/cp/Documents/envMyShopUp/local/lib/python2.7/site-packages/django/db/models/lookups.py" in __init__105. self.rhs = self.get_prep_lookup()
File "/home/cp/Documents/envMyShopUp/local/lib/python2.7/site-packages/django/db/models/lookups.py" in get_prep_lookup143. return self.lhs.output_field.get_prep_lookup(self.lookup_name, self.rhs)
File "/home/cp/Documents/envMyShopUp/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py" in get_prep_lookup729. return [self.get_prep_value(v) for v in value]
File "/home/cp/Documents/envMyShopUp/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py" in get_prep_value985. return int(value)Exception Type: ValueError at /customapi/vendor/customer-requirements/
Exception Value: invalid literal for int() with base 10: '1,4'
Thanks in advance.