Closed DavidMuller closed 9 years ago
Ah--looks like my build failed on versions of Django != 1.7, because custom lookups were a feature added for 1.7.
Happy to rework this to get it going on all versions--let me know what you guys think!
Did you get anywhere with this feature? Are you using it in production?
@nemesisdesign -- played around with it for a while, but ultimately decided to leverage Django 1.8's built-in hstore support
Build Failed Update
Looks like my build failed on versions of Django != 1.7, because custom lookups were a feature added for 1.7.
Happy to rework this to get it going on all versions--let me know what you guys think!
Overview
This PR adds a new lookup:
valuelike
Motivation:
Currently, the
contains
lookup, only retrieves database rows that have key/value pairs that exactly match your inputted dictionary. For example, running a__contains={'my_key': 'my_value'}
only returns database rows that have an exact match on the key/value pair'my_key': 'my_value'
Changes:
The
valuelike
lookup, e.g.__valuelike={'my_key': 'my_value'}
, will retrieve a QuerySet containing rows where'my_key'
has a value LIKE %my_value%.'my_key'
is not in any of the database rows, returned QuerySet will be empty'my_key'
is in one or more database rows, checks value of'my_key'
for a match with LIKE %my_value%.Usage Example:
Case Sensitivity
This PR also adds the
ivaluelike
lookup which is identical tovaluelike
except that it uses the case insensitive version of the LIKE clause (ILIKE).