Is there a way to use an expression in django filter function like a key.
I am trying to do this:
models.Product.objects.filter("name_cn" = "smth")
and get an error:
SyntaxError: keyword can't be an expression
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If
name_cnis a variable, then put it in a dictionary, and deliver the keyword arguments in your dictionary using the**operator:If
"name_cn"is the name of the field you want to filter on, then try: