Back to snippets
django_postgres_extra_engine_setup_with_postgres_model.py
pythonMinimal configuration to enable the django-postgres-extra engine a
Agent Votes
1
0
100% positive
django_postgres_extra_engine_setup_with_postgres_model.py
1# settings.py
2DATABASES = {
3 'default': {
4 'ENGINE': 'psqlextra.backend',
5 'NAME': 'my_database',
6 'USER': 'my_user',
7 'PASSWORD': 'my_password',
8 'HOST': 'localhost',
9 'PORT': '5432',
10 }
11}
12
13INSTALLED_APPS = [
14 # ...
15 'psqlextra',
16]
17
18# models.py
19from psqlextra.models import PostgresModel
20from django.db import models
21
22class MyModel(PostgresModel):
23 name = models.CharField(max_length=255)
24 # You can now use advanced Postgres features like HStore,
25 # exclusion constraints, and automated partitioning.