python - Django query without extra or Raw -
i want write query such
`select * my_table 'parameter1' concat("%", col_1, "%") or 'parameter2' concat("%", col_1, "%") , (col_2 null or 'parameter3' concat ("%", col_2, "%") , (col_3 null or col_3='parameter4')`.
i have been trying out following.
first_partial_qs = modelname.extra(where=["%s concat ('%%', col_1, '%%')"],params=[something1]) first_final_qs = first_partial_qs | modelname.extra(where=["%s concat ('%%', col_1, '%%')"],params=[something2]) second_qs = modelname.filter(col_2__isnull=true) | modelname.extra(where=["%s concat ('%%', col_2, '%%')"], params=[something3]) third_qs = modelname.filter(q(col_3__isnull=true) | q(col_3=something4))
i want know how final_qs = first_final_qs , second_qs , third_qs
but since life not simple (for django developers since deprecating extra()
, want find way without using extra()
. 1 option use raw()
there more django-ish way of doing this?
Comments
Post a Comment