Skip to content

Instantly share code, notes, and snippets.

View jeffclay's full-sized avatar

Jeff Clay jeffclay

  • USA
  • 19:32 (UTC -05:00)
View GitHub Profile
@axelbdt
axelbdt / django-postgresql-15.md
Last active April 22, 2025 16:38
# Django and PostgreSQL 15, the rules have changed

Django and PostgreSQL 15, the rules have changed

Postgres 15 is just out, and while there is a lot to love about this new release, you're in for a surprise if you try to set it up with Django following tutorials like this one.

The reason is stated in the release announcement:

Remove PUBLIC creation permission on the public schema (Noah Misch) The new default is one of the secure schema usage patterns that Section 5.9.6 has recommended...

Provided your web app doesn't access your database as a superuser (it shouldn't) and uses a dedicated user, it is not allowed to use the public schema anymore. You have to create one for this specific user, and the next section will

@ranelpadon
ranelpadon / sync_migrations.py
Created July 6, 2022 20:07
Prevent "duplicate table/column" errors when running migrations due to a similarly named, previously ran migration
"""
manage.py sync_migrations
"""
import re
from django.core.management.base import BaseCommand
from django.db import (
DEFAULT_DB_ALIAS,
connections,
)
@ms5
ms5 / verbos-argpary-example.py
Last active July 19, 2024 12:19
manipulating log level with python argparse
import argparse
import logging
parser = argparse.ArgumentParser()
parser.add_argument('--verbose', '-v', action='count', default=1)
args = parser.parse_args()
args.verbose = 70 - (10*args.verbose) if args.verbose > 0 else 0
logging.basicConfig(level=args.verbose, format='%(asctime)s %(levelname)s: %(message)s',