I’m pretty new to Django. I have just learnt that could filter a query set this 
way: 

Questions.objects.filter(question_text__contains=‘what’)

This kind of scares me a little because the filter “contains” is actually part 
of the field name. And I guess there are other operators appended to a field 
with the same __operation pattern.

Wouldn’t this make refactoring tricky? Even renaming the field name has to be 
done carefully. In my mind, this feels messy. 

Is there an alternative to doing this? Something like:
Questions.objects.filter(question_text.contains=‘what’)
Or using “contains” as a function?

Basically, can I do the same thing without adding “magic strings” to field 
names?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3f7194e9-b600-4a14-be1e-83f0cb35dac6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to