0

I am new in Django.

In my Django view.py, I have following get method: customer_list = Customer.objects.filter(CustId = '1001') and it returns result.

When I substitute with a String like following:

getQueryString = "CustId = '1001'"
customer_list = Customer.objects.filter(getQueryString)

I get the following error:

too many values to unpack (expected 2)

Any help really appreciated.

damon
  • 14,485
  • 14
  • 56
  • 75
Deysgroup
  • 93
  • 4

2 Answers2

0

Hi @Deysgroup if you want send like that you can use getQueryString={'CustId': '1001'} and then call the function using customer_list = Customer.objects.filter(**getQueryString), I hope that this answer helps you.

C. Marca
  • 23
  • 1
  • 8
0

Have you tried using a dict?

Take a look at this question, perhaps it can help you understand your problem.

getQueryString = {'CustId': '1001'}
customer_list = Customer.objects.filter(**getQueryString)
Bernardo Duarte
  • 4,074
  • 4
  • 19
  • 34