PostgreSQL lookups and functions for Django apps
How often have you had the impression that Django was not providing all the lookup expressions and functions for your queries? Probably not that often, but now here is a small collection that I consider quite useful.
Installation
Just use:
pip install django-postgres-tweaks
As the title says it already, these tools are designed to be used in Django projects/apps. So make
sure to add postgres_utils or postgres_utils.apps.PostgresUtilsConfig to the INSTALLED_APPS
list in your project's settings.py!
That's it.
Usage
Lookups
The lookups provided by this package/app are automatically loaded when the app is installed. You can go ahead and just use them like Django's built-in lookups, e.g.:
Pizza.objects.filter(name__noregex="[ ]+")
Assume you have a model called Pizza with a name field.
Functions
Like the DB functions provided by Django, e.g. in django.db.models.functions, you need to need
to import them prior to usage. An example query looks like this:
Topping.objects\
.filter(name__contains="Onion")\
.annotate(onion_color=RegexpReplace("name", " *Onion$", ""))\
.values("name", "onion_color")\
.order_by("name")
Metadata
Release files for django-postgres-tweaks 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-postgres-tweaks-0.1.3.tar.gz | 5.0 kB | Without provenance | Details for django-postgres-tweaks-0.1.3.tar.gz |
Release files / django-postgres-tweaks-0.1.3.tar.gz
| Download URL | django-postgres-tweaks-0.1.3.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0a53366a98d264e8c52eccd359e845f70314f1b60562d24ba0a4b626d897c7a0
|
|
BLAKE2b-256 checksum How to use checksums |
1358ca8abbbf4b09ba56359f2864f81575bbb67c74db13eedcbd05858b9d7191
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.7
|
Security for django-postgres-tweaks 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.