diff --git a/demo/management/commands/setup_demo_template_db.py b/demo/management/commands/setup_demo_template_db.py index 78bb043644..c9b1ce20b7 100644 --- a/demo/management/commands/setup_demo_template_db.py +++ b/demo/management/commands/setup_demo_template_db.py @@ -20,7 +20,7 @@ def _setup_demo_template_db(): print("Initializing demo template database...") template_db_name = settings.MATHESAR_DEMO_TEMPLATE - django_model = Database.current_objects.get(name=settings.DATABASES["default"]["NAME"]) + django_model = Database.create_from_settings_key("default") root_engine = create_mathesar_engine(django_model) with root_engine.connect() as conn: conn.execution_options(isolation_level="AUTOCOMMIT") diff --git a/demo/settings.py b/demo/settings.py index 94117c4084..2288b5d7f8 100644 --- a/demo/settings.py +++ b/demo/settings.py @@ -1,5 +1,4 @@ -from config.settings.production import * # noqa -from config.settings import * # noqa +from config.settings.common_settings import * # noqa from decouple import config as decouple_config INSTALLED_APPS += [ # noqa @@ -10,6 +9,7 @@ "demo.middleware.LiveDemoModeMiddleware", ] +MATHESAR_MODE = 'PRODUCTION' MATHESAR_LIVE_DEMO = True MATHESAR_LIVE_DEMO_USERNAME = decouple_config('MATHESAR_LIVE_DEMO_USERNAME', default=None) MATHESAR_LIVE_DEMO_PASSWORD = decouple_config('MATHESAR_LIVE_DEMO_PASSWORD', default=None) diff --git a/mathesar/install.py b/mathesar/install.py index 3efaa9bd00..466c0c982b 100644 --- a/mathesar/install.py +++ b/mathesar/install.py @@ -37,6 +37,14 @@ def main(skip_static_collection=False): install_on_db_with_key(database_key, skip_confirm) except IntegrityError: continue + if getattr(settings, 'MATHESAR_LIVE_DEMO', False) is True: + management.call_command( + 'createsuperuser', + '--no-input', + '--username', 'demo', + '--email', 'admin@example.com', + ) + management.call_command('setup_demo_template_db') def install_on_db_with_key(database_key, skip_confirm):