I’m trying to use a string as a parameter in a function. Is something like this possible?
from django.contrib.auth.models import User
param_var = 'contains'
User.objects.filter(first_name__{param_var}='John')
# ideally, this should equate to:
User.objects.filter(first_name__contains='John')
Though I really wonder about the wisdom of doing that… I think you may be re-inventing sql injection…
I suspect there’s a better way. You should probably explain more of what you are trying to accomplish.