Skip to main content

Special PostgreSQL lookups and functions for Django apps

Project description

PostgreSQL lookups and functions for Django apps

Build Status Documentation Status

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")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-postgres-tweaks-0.1.2.tar.gz (5.0 kB view details)

Uploaded Source

File details

Details for the file django-postgres-tweaks-0.1.2.tar.gz.

File metadata

  • Download URL: django-postgres-tweaks-0.1.2.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for django-postgres-tweaks-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4fef5a94a1e116e0fcf273e48a8cfab300280c2d8bedd84f0e50de252403cf24
MD5 c0d4bbd90ffaab11f6860254a37d17a5
BLAKE2b-256 843dfac9b975a9a5d878b5774eb5f58bd3a0c4c706e90b24ceb2d12962a7a34a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page