On Sunday 14 February 2016 05:52:32 belorn mandos wrote:
> On Saturday, February 13, 2016 at 9:17:34 PM UTC+1, Shai Berger wrote:
> > val = int(s) if s else None
> >
> > will make your code clearer and safer against unexpected inputs than what
> > you
> > have currently, and certainly cleaner than using __iexact.
>
> I was thinking in the line of wrapping the Q on the condition of
> isnumeric:
>
> (Q(org_name=criteria) | (Q(org_number=int(criteria)) if
> criteria.isnumeric() else False)
>
I'm not sure `False` can be used as a Q object, and you also need to take care
that criteria is strip()'ed of whitespace; but this is going deep into
django-users territory.
HTH,
Shai.