Skip to main content

Prerequisites

  • GCC

  • Python 3.8 and above

  • Psycopg2-yugabytedb (recommended)

  • Django 3.2 or above

Need for Django Backend for YugabyteDB

YugabyteDB needs a separate backend for Django. This is because of mainly 3 reasons.

  • Django tries to create Inet data types as primary keys in Django test suites. Since this is not supported, we map Inet types to varchar(15) and varchar(39) in the YB backend.

  • We also need it to support type change from int to BigInt and numeric(m,n) to double precision. This is required for Django DB migrations. For now, the YB backend ignores these type changes.

  • The Django PostgreSQL Backend does not support the Load Balance, even when used with YugabyteDB smart driver.

Installing from Pypi

Install the django-yugabytedb package with the command:

$ pip install django-yugabytedb

Installing in Python Virtual Environment From Source

The django-yugabytedb package can also be installed from source:

$ git clone https://github.com/yugabyte/yb-django.git

$ python -m pip install -r <repo_path>/yb-django/requirements.txt

$ python -m pip install -e <repo_path>/yb-django/

Check if it is installed correctly:

$ pip list —local

Use the backend with your Application

Update the DATABASES setting in your Django project’s settings to point to YB server using Django YB backend:

DATABASES = {
    'default': {
        'ENGINE': 'django_yugabytedb',
        'NAME': 'yugabyte',
        'HOST': 'localhost',
        'PORT': 5433,
        'USER': 'yugabyte',
    }
}

To use Cluster Aware Load Balance:

DATABASES = {
    'default': {
        'ENGINE': 'django_yugabytedb',
        'NAME': 'yugabyte',
        'HOST': 'localhost',
        'PORT': 5433,
        'USER': 'yugabyte',
        'LOAD_BALANCE': 'True'
    }
}

To use Topology Aware Load Balance:

DATABASES = {
    'default': {
        'ENGINE': 'django_yugabytedb',
        'NAME': 'yugabyte',
        'HOST': 'localhost',
        'PORT': 5433,
        'USER': 'yugabyte',
        'LOAD_BALANCE': 'True',
        'TOPOLOGY_KEYS': 'cloud1.region1.zone1'
    }
}

Known bugs and issues

  • The creation of indexes in YugabyteDB is a little slow.

  • Since Inet is mapped to varchar in the backend, comparison between data in the inet column wth Inet type will fail.

  • For YugabyteDB verions earlier than 2.9, the savepoint feature is not supported.

  • Dropping of Primary keys are not supported

  • Alter table Add column Unique is not yet supported.

  • Backfilling of existing rows when new column is added with default value is not yet implemented in yugabytedb.

  • Type change from int to BigInt and numeric(m,n) to double precision is not yet supported.

  • ALTER INDEX not supported yet.

Release files for django-yugabytedb 4.2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-yugabytedb 4.2.0.1
File Size Uploaded
django_yugabytedb-4.2.0.1.tar.gz 12.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-yugabytedb 4.2.0.1
File Interpreter ABI Platform
django_yugabytedb-4.2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 24.2 kB

Release files / django_yugabytedb-4.2.0.1.tar.gz

Download URL django_yugabytedb-4.2.0.1.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2c03362c54b190ec935ee6d057ed39ba7db90c02b6e773698ba1d5248f8a4c94
BLAKE2b-256 checksum
How to use checksums
18fff93d21e5c7e5ad9618018750938b2c573c8a0e12d2ccd09e021caa725ec0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.17

Release files / django_yugabytedb-4.2.0.1-py3-none-any.whl

Download URL django_yugabytedb-4.2.0.1-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0679be0e052e2eb65edb1a7d262692eafb8dff0c59741c8102559f1efa9c0b03
BLAKE2b-256 checksum
How to use checksums
992ef4a022a82a0dce8ad3a88d28f00713e8969cead16d54f3faa82e5e18ced8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.17

Release history Release notifications | RSS feed

This release

4.2.0.1 This release

2 release files

4.2.0

2 release files

4.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page