Answer the question
In order to leave comments, you need to log in
How to select an object in which the field is the beginning of the line?
there is path = name1/qqqq/qq
in the table there is:
name=name1/q
name=name2
you need to extract the object with name=name1/q, because "name1/q" is the beginning of path.
ORM tools.
Answer the question
In order to leave comments, you need to log in
so it turned out
Model.objects.annotate(screen_name=V(path, output_field=CharField())).filter(screen_name__startswith=F('name'))
So just break the path into substrings. You can split on the symbol "/" and just throw the desired part of the substring as a parameter in sql
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question