Django lookup extensions¶
Django lookup extensions use NOT query.
- Free software: MIT license
- Documentation: https://django-lookup-extensions.readthedocs.io.
Installation¶
To install Django lookup extensions, run this command in your terminal:
$ pip install django-lookup-extensions
This is the preferred method to install Django lookup extensions, as it will always install the most recent stable release.
If you don’t have pip installed, this Python installation guide can guide you through the process.
Usage¶
Setup¶
Add ‘lookup_extensions’ to your INSTALLED_APPS setting.:
INSTALLED_APPS = [
...
'lookup_extensions',
...
]
AppConfig.ready imports lookups and register them using django.db.models.fields.Field.register_lookup.
Making queries¶
Use lookup like Django standard lookups.
ModelA.objects.filter(name__neexact='test name')
Supported lookup types¶
Negaetes¶
neexact is negate exact, neiexact is negate iexact, others are similar.
- neexact
- neiexact
- necontains
- neicontains
- nestartswith
- neendswith
- neistartswith
- neiendswith
- neregex
- neiregex
Complement¶
- complement
Extra regexes¶
These regex lookups support metacharacters \d, \D, w, \W, \s, \S.
MySQL, PostgreSQL and Redshift also support \<, \>.
Prefix follows the previous section.
- exregex
- exiregex
- neexregex
- neexiregex
Supported vendor types¶
- MySQL
- PostgreSQL
- sqlite
- lookups using LIKE aren’t case sensitive.
- necontains
- nestartswith
- neendswith
- lookups using LIKE aren’t case sensitive.
- Redshift
Credits¶
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.