{"id":21140,"library":"django-clickhouse-backend","title":"Django ClickHouse Backend","description":"A Django database backend for ClickHouse, providing ORM integration, migrations, and support for ClickHouse-specific features like MergeTree engines, distributed tables, and materialized views. Current version 1.6.0, released April 2025. Active development with quarterly releases.","status":"active","version":"1.6.0","language":"python","source_language":"en","source_url":"https://github.com/jayvynl/django-clickhouse-backend","tags":["django","clickhouse","database","backend","orm","olap"],"install":[{"cmd":"pip install django-clickhouse-backend","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The backend is a package, not a module. Import the package and configure DATABASES engine as 'clickhouse_backend.backend'","wrong":"from clickhouse_backend import ...","symbol":"clickhouse_backend","correct":"import clickhouse_backend"},{"note":"DatabaseOperations is in the operations submodule","wrong":"from clickhouse_backend import DatabaseOperations","symbol":"DatabaseOperations","correct":"from clickhouse_backend.operations import DatabaseOperations"}],"quickstart":{"code":"import os\n\n# Configure Django settings\nDATABASES = {\n    'default': {\n        'ENGINE': 'clickhouse_backend.backend',\n        'NAME': 'default',\n        'USER': os.environ.get('CLICKHOUSE_USER', 'default'),\n        'PASSWORD': os.environ.get('CLICKHOUSE_PASSWORD', ''),\n        'HOST': os.environ.get('CLICKHOUSE_HOST', 'localhost'),\n        'PORT': os.environ.get('CLICKHOUSE_PORT', '8123'),\n        'OPTIONS': {\n            'settings': {\n                'mutations_sync': 2,\n            },\n        },\n    }\n}\n\n# Verify connection\nfrom django.db import connection\nwith connection.cursor() as cursor:\n    cursor.execute('SELECT version()')\n    print(cursor.fetchone())","lang":"python","description":"Configure Django to use ClickHouse backend and test the connection."},"warnings":[{"fix":"Upgrade to django-clickhouse-backend >= 1.4.0","message":"Django 5.2 and above require django-clickhouse-backend >= 1.4.0. Using older versions with Django 5.2 will cause import errors.","severity":"breaking","affected_versions":"django-clickhouse-backend < 1.4.0 with Django >= 5.2"},{"fix":"Avoid using db_default with bulk_create, or patch the DatabaseOperations class to handle default resolution. Fixed in future releases.","message":"Bulk_create uses db_default and default expressions incorrectly in v1.6.0. The default value object may appear in SQL instead of being resolved. This only affects bulk_create with db_default set.","severity":"gotcha","affected_versions":"1.6.0"},{"fix":"Replace index_together with Meta.indexes and upgrade django-clickhouse-backend to >= 1.3.1","message":"index_together is deprecated in Django 5.1 and removed in 5.2. Use Meta.indexes instead.","severity":"deprecated","affected_versions":"Django >= 5.1 with django-clickhouse-backend < 1.3.1"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run: pip install django-clickhouse-backend","cause":"The clickhouse_backend package is not installed or not in PYTHONPATH.","error":"django.core.exceptions.ImproperlyConfigured: 'clickhouse_backend.backend' isn't an available database backend."},{"fix":"Upgrade to django-clickhouse-backend >= 1.1.7","cause":"Using a ReplicatedReplacingMergeTree with a version column (ver) in older versions (<1.1.7). The engine's expressions attribute is missing.","error":"AttributeError: 'ReplicatedReplacingMergeTree' object has no attribute 'expressions'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}