python - getting error while using queryset Q in django view -


i creating dynamic queryset using q while printing

build_query[:-1] 

i getting output

q(owner_id=1)|q(assigned_to=1) 

but when using in

consultants = consultant.objects.filter(*build_query[:-1]) 

getting error many values unpack tried ** , without * still not working. when check type of

print type(build_query[:-1]) 

i getting string type. main cause?

traceback

internal server error: /api/consultants/my_consultants/ traceback (most recent call last):   file "/home/jagmeet/consultadd_workspace/devenv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response     response = wrapped_callback(request, *callback_args, **callback_kwargs)   file "/home/jagmeet/consultadd_workspace/devenv/local/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 57, in wrapped_view     return view_func(*args, **kwargs)   file "/home/jagmeet/consultadd_workspace/devenv/local/lib/python2.7/site-packages/rest_framework/viewsets.py", line 85, in view     return self.dispatch(request, *args, **kwargs)   file "/home/jagmeet/consultadd_workspace/devenv/local/lib/python2.7/site-packages/rest_framework/views.py", line 451, in dispatch     response = self.handle_exception(exc)   file "/home/jagmeet/consultadd_workspace/devenv/local/lib/python2.7/site-packages/rest_framework/views.py", line 448, in dispatch     response = handler(request, *args, **kwargs)   file "/home/jagmeet/consultadd_workspace/devenv/ckiller/consultants/api.py", line 170, in my_consultants     consultants = consultant.objects.filter(*build_query[:-1])   file "/home/jagmeet/consultadd_workspace/devenv/local/lib/python2.7/site-packages/django/db/models/manager.py", line 92, in manager_method     return getattr(self.get_queryset(), name)(*args, **kwargs) q(owner_id=1)|q(assigned_to=1)   file "/home/jagmeet/consultadd_workspace/devenv/local/lib/python2.7/site-packages/django/db/models/query.py", line 691, in filter     return self._filter_or_exclude(false, *args, **kwargs)   file "/home/jagmeet/consultadd_workspace/devenv/local/lib/python2.7/site-packages/django/db/models/query.py", line 709, in _filter_or_exclude     clone.query.add_q(q(*args, **kwargs))   file "/home/jagmeet/consultadd_workspace/devenv/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1331, in add_q     clause, require_inner = self._add_q(where_part, self.used_aliases) 

consultants = consultant.objects.filter(*build_query[:-1])

did u try:

consultant.objects.filter(*[build_query[:-1],])

args should list


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -