diff --git a/src/plugins/export/ExportDjango.py b/src/plugins/export/ExportDjango.py index 1dc310649..2f7905cfb 100644 --- a/src/plugins/export/ExportDjango.py +++ b/src/plugins/export/ExportDjango.py @@ -61,7 +61,7 @@ ngettext = translator.ngettext from django.conf import settings import web.settings as default_settings try: - settings.configure(default_settings, DEBUG=True) + settings.configure(default_settings) except RuntimeError: # already configured; ignore pass diff --git a/src/web/grampsdb/models.py b/src/web/grampsdb/models.py index 80943f6ab..f35e47084 100644 --- a/src/web/grampsdb/models.py +++ b/src/web/grampsdb/models.py @@ -675,13 +675,31 @@ TABLES = [ ("ref", MediaRef) ] +def no_style(): + """Returns a Django Style object that has no colors.""" + class dummy(object): + def __getattr__(self, attr): + return lambda x: x + return dummy() + def clear_tables(*categories): """ Clear the entries of categories of tables. Category is: "abstract", "type", "ref", "meta", "primary" and "secondary". """ - for pair in get_tables(*categories): - pair[1].objects.all().delete() + from django.db import connection, transaction + cursor = connection.cursor() + flush_tables = [] + for (category, model) in get_tables(*categories): + flush_tables.append(model._meta.db_table) + # tables = connection.introspection.table_names() + # flush_tables = [table for table in tables if not table.endswith("type")] + statements = connection.ops.sql_flush(no_style(), + flush_tables, + connection.introspection.sequence_list()) + for statement in statements: + cursor.execute(statement) + transaction.commit_unless_managed() def table_stats(*categories): """ diff --git a/src/web/settings.py b/src/web/settings.py index b3072413f..26289b1c2 100644 --- a/src/web/settings.py +++ b/src/web/settings.py @@ -3,7 +3,7 @@ import const import os -DEBUG = True +DEBUG = False TEMPLATE_DEBUG = DEBUG INTERNAL_IPS = ('127.0.0.1',) @@ -49,7 +49,7 @@ TEMPLATE_DIRS = ( TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.auth", - "django.core.context_processors.debug", +# "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", "web.grampsdb.views.context_processor", @@ -66,27 +66,27 @@ INSTALLED_APPS = ( # 'debug_toolbar', ) -DEBUG_TOOLBAR_PANELS = ( - 'debug_toolbar.panels.version.VersionDebugPanel', - 'debug_toolbar.panels.timer.TimerDebugPanel', - 'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel', - 'debug_toolbar.panels.headers.HeaderDebugPanel', - 'debug_toolbar.panels.request_vars.RequestVarsDebugPanel', - 'debug_toolbar.panels.template.TemplateDebugPanel', - 'debug_toolbar.panels.sql.SQLDebugPanel', - 'debug_toolbar.panels.signals.SignalDebugPanel', - 'debug_toolbar.panels.logger.LoggingPanel', - ) +#DEBUG_TOOLBAR_PANELS = ( +# 'debug_toolbar.panels.version.VersionDebugPanel', +# 'debug_toolbar.panels.timer.TimerDebugPanel', +# 'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel', +# 'debug_toolbar.panels.headers.HeaderDebugPanel', +# 'debug_toolbar.panels.request_vars.RequestVarsDebugPanel', +# 'debug_toolbar.panels.template.TemplateDebugPanel', +# 'debug_toolbar.panels.sql.SQLDebugPanel', +# 'debug_toolbar.panels.signals.SignalDebugPanel', +# 'debug_toolbar.panels.logger.LoggingPanel', +# ) -def custom_show_toolbar(request): - return True # Always show toolbar, for example purposes only. +#def custom_show_toolbar(request): +# return True # Always show toolbar, for example purposes only. -DEBUG_TOOLBAR_CONFIG = { - 'INTERCEPT_REDIRECTS': True, -# 'SHOW_TOOLBAR_CALLBACK': custom_show_toolbar, -# 'EXTRA_SIGNALS': ['myproject.signals.MySignal'], - 'HIDE_DJANGO_SQL': False, - } +#DEBUG_TOOLBAR_CONFIG = { +# 'INTERCEPT_REDIRECTS': True, +## 'SHOW_TOOLBAR_CALLBACK': custom_show_toolbar, +## 'EXTRA_SIGNALS': ['myproject.signals.MySignal'], +# 'HIDE_DJANGO_SQL': False, +# } # Had to add these to use settings.configure(): DATABASE_OPTIONS = ''