0

I have a checkbox where I am selecting variables for django filter values. I am getting the values correctly so if I replace *values with pfast_type[0] or pfast_type[1] it works fine.

But What I want to do is that if I select 3 variables checkbox I want this entered like pfast_type[0], pfast_type[1] and pfast_type[2], if I select one 1 variable it should be only pfast_type[0] for the values.

Where am I going wrong?

Maybe I am searching poorly but I searched and couldn't find any reference information within the StackOverflow.

pfast_type = request.GET.getlist("pfast_type")
elif pfast_type and items:
    for pfast_type in range(len(pfast_type)):
        values= values.append(pfast_type[i])
        object_list = FP.objects.filter(pk__in=items).values('RFP_Item',*values)
1
  • try to add meaning to your variable names. your code is hard to understand Commented Jun 6, 2018 at 18:41

1 Answer 1

2

You don't need *values and the loop, simply try this:

object_list = RFP.objects.filter(pk__in=items).values('FP_Item',*pfast_type)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.