How to get all field from DB where value have number?
Example valid: 1test, tes1t, test1
I suppose something like this: field__contains
How to get all field from DB where value have number?
Example valid: 1test, tes1t, test1
I suppose something like this: field__contains
You can do this with a regex query.
Model.objects.filter(value__regex=r'\d')
Use icontains
: django docs.
objs = Model.objects.filter(value__icontains="1")
The equivalent of doing an sql ILIKE "%1%"
(case insensitive)
contains
may work just as well actually if it's a number, that's a simple LIKE
Edit: To answer your comment yes you'd need to loop over the numbers. See this question