3👍
✅
I think I’ve found a horrible way to do it in the ORM without needing raw SQL. Hopefully someone else will be able to find something better.
from django.db.models import ExpressionWrapper, CharField, Value, F
param = 'Starbucks Pike Place'
myparam = ExpressionWrapper(Value(param), output_field=CharField())
Place.objects.annotate(param=myparam).filter(param__contains=F('username'))
👤wim
0👍
Place.objects.get(name__contains=PARAM)
should do it. Note that you can also use icontains
instead of contains
if you’d like the query to be case-insensitive.
- [Django]-How to make permission for groups and administrators
- [Django]-WSGI weirdness with PYthon/Django: serving alternating old and new versions of app
- [Django]-How to serve Google Cloud Storage images?
- [Django]-Creating a Like-Gate (reveal tab) for a Facebook app, using Django/Python
Source:stackexchange.com