allow arbitrary path for sqlite using DATABASE_URL

This commit is contained in:
smilerz 2023-10-30 21:54:25 -05:00
parent e89c1742fb
commit 8bee2e3976
No known key found for this signature in database
GPG Key ID: 39444C7606D47126

View File

@ -358,6 +358,8 @@ if os.getenv('DATABASE_URL'):
if schema.startswith('postgres'):
engine = 'django.db.backends.postgresql'
elif schema == 'sqlite':
if not os.path.exists(db_path := os.path.dirname(settings['database'])):
os.makedirs(db_path)
engine = 'django.db.backends.sqlite3'
else:
raise Exception("Unsupported database schema: '%s'" % schema)