How would I do the following query?
SELECT * FROM title WHERE id LIKE '12345%'
What I currently have is:
Title.objects.get(id='12345')
Which obviously doesn't do the LIKE% (and the icontains does both). What would be the correct query here?
Title.objects.filter(id__startswith='12345')
https://docs.djangoproject.com/en/dev/ref/models/querysets/
You can do like this where code would be your startswith string by which you want to filter the table.
code = '12345' enter code hereTitle.objects.extra(where=["%s LIKE id||'%%'"], params=[code])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With