A
A
Antigo_ptz2017-01-11 17:41:05
Django
Antigo_ptz, 2017-01-11 17:41:05

Django how to pass custom parameter to filter?

I need to pass the parameter value from the variable to the filter:

parameter = 'blog__id'
Entry.objects.filter(parameter=3)

As done in the code above, it won't work. How can I do this, does anyone have any thoughts?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly Scherbakov, 2017-01-11
@Antigo_ptz

Entry.objects.filter(**{parameter: 3})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question