When using PostgresHuey, you should disable automatic table creation to avoid conflicts with Django migrations and permission issues. Use the create_huey_tables management command to create tables explicitly.
To reuse your existing Django database credentials without duplicating them, provide a connection callable in your HUEY settings. This callable must return a new, dedicated psycopg connection (do not return django.db.connection).
# settings.py
import psycopg
from django.conf import settings
def huey_connection():
db = settings.DATABASES['default']
return psycopg.connect(
dbname=db['NAME'],
user=db.get('USER') or None,
password=db.get('PASSWORD') or None,
host=db.get('HOST') or None,
port=db.get('PORT') or None)
HUEY = {
'huey_class': 'huey.PostgresHuey',
'create_tables': False,
'connection': {'connection': huey_connection},
}
To create the tables, run:
./manage.py create_huey_tables