def performance(request): """Show performance tuning tips.""" checks = [] # Check for debug mode checks.append(( _('Debug mode'), not settings.DEBUG, 'production-debug', settings.DEBUG, )) # Check for domain configuration domain = Site.objects.get_current().domain checks.append(( _('Site domain'), check_domain(domain), 'production-site', domain, )) # Check database being used checks.append(( _('Database backend'), "sqlite" not in settings.DATABASES['default']['ENGINE'], 'production-database', settings.DATABASES['default']['ENGINE'], )) # Check configured admins checks.append(( _('Site administrator'), len(settings.ADMINS) > 0 or '*****@*****.**' in [x[1] for x in settings.ADMINS], 'production-admins', ', '.join([x[1] for x in settings.ADMINS]), )) # Check offloading indexing checks.append(( # Translators: Indexing is postponed to cron job _('Indexing offloading'), settings.OFFLOAD_INDEXING, 'production-indexing', settings.OFFLOAD_INDEXING)) if settings.OFFLOAD_INDEXING: if IndexUpdate.objects.count() < 20: index_updates = True elif IndexUpdate.objects.count() < 200: index_updates = None else: index_updates = False checks.append(( # Translators: Indexing is postponed to cron job _('Indexing offloading processing'), index_updates, 'production-indexing', IndexUpdate.objects.count(), )) # Check for sane caching caches = settings.CACHES['default']['BACKEND'].split('.')[-1] if caches in ['MemcachedCache', 'PyLibMCCache', 'DatabaseCache']: # We consider these good caches = True elif caches in ['DummyCache']: # This one is definitely bad caches = False else: # These might not be that bad caches = None checks.append(( _('Django caching'), caches, 'production-cache', settings.CACHES['default']['BACKEND'], )) # Avatar caching checks.append(( _('Avatar caching'), 'avatar' in settings.CACHES, 'production-cache-avatar', settings.CACHES['avatar']['BACKEND'] if 'avatar' in settings.CACHES else '', )) # Check email setup default_mails = ('root@localhost', 'webmaster@localhost', '*****@*****.**') checks.append(( _('Email addresses'), (settings.SERVER_EMAIL not in default_mails and settings.DEFAULT_FROM_EMAIL not in default_mails), 'production-email', ', '.join((settings.SERVER_EMAIL, settings.DEFAULT_FROM_EMAIL)), )) # libravatar library checks.append(( _('Federated avatar support'), HAS_LIBRAVATAR, 'production-avatar', HAS_LIBRAVATAR, )) # pyuca library checks.append(( _('pyuca library'), HAS_PYUCA, 'production-pyuca', HAS_PYUCA, )) # Cookie signing key checks.append(( _('Secret key'), settings.SECRET_KEY != settings_example.SECRET_KEY, 'production-secret', '', )) # Allowed hosts checks.append(( _('Allowed hosts'), len(settings.ALLOWED_HOSTS) > 0, 'production-hosts', ', '.join(settings.ALLOWED_HOSTS), )) loader = get_first_loader() # Cached template loader checks.append(( _('Cached template loader'), 'cached.Loader' in loader, 'production-templates', loader, )) # Check for serving static files checks.append(( _('Admin static files'), os.path.exists( os.path.join(settings.STATIC_ROOT, 'admin', 'js', 'core.js')), 'production-admin-files', settings.STATIC_ROOT, )) context = admin_context(request) context['checks'] = checks context['errors'] = get_configuration_errors() return render( request, "admin/performance.html", context, )
def performance(request): """ Shows performance tuning tips. """ checks = [] # Check for debug mode checks.append(( _('Debug mode'), not settings.DEBUG, 'production-debug', )) # Check for domain configuration checks.append(( _('Site domain'), Site.objects.get_current().domain not in DEFAULT_DOMAINS, 'production-site', )) # Check database being used checks.append(( _('Database backend'), "sqlite" not in settings.DATABASES['default']['ENGINE'], 'production-database', )) # Check configured admins checks.append(( _('Site administrator'), len(settings.ADMINS) > 0, 'production-admins', )) # Check offloading indexing checks.append(( # Translators: Indexing is postponed to cron job _('Indexing offloading'), appsettings.OFFLOAD_INDEXING, 'production-indexing', )) if appsettings.OFFLOAD_INDEXING: checks.append(( # Translators: Indexing is postponed to cron job _('Indexing offloading processing'), IndexUpdate.objects.count() < 20, 'production-indexing', )) # Check for sane caching caches = settings.CACHES['default']['BACKEND'].split('.')[-1] if caches in ['MemcachedCache', 'DatabaseCache']: # We consider these good caches = True elif caches in ['DummyCache']: # This one is definitely bad caches = False else: # These might not be that bad caches = None checks.append(( _('Django caching'), caches, 'production-cache', )) # Avatar caching checks.append(( _('Avatar caching'), 'avatar' in settings.CACHES, 'production-cache-avatar', )) # Check email setup default_mails = ('root@localhost', 'webmaster@localhost', '*****@*****.**') checks.append(( _('Email addresses'), (settings.SERVER_EMAIL not in default_mails and settings.DEFAULT_FROM_EMAIL not in default_mails), 'production-email', )) # libravatar library checks.append(( _('Federated avatar support'), HAS_LIBRAVATAR, 'production-avatar', )) # pyuca library checks.append(( _('pyuca library'), HAS_PYUCA, 'production-pyuca', )) # Cookie signing key checks.append(( _('Secret key'), settings.SECRET_KEY != settings_example.SECRET_KEY, 'production-secret', )) # Allowed hosts checks.append(( _('Allowed hosts'), len(settings.ALLOWED_HOSTS) > 0, 'production-hosts', )) # Cached template loader checks.append((_('Cached template loader'), 'cached.Loader' in settings.TEMPLATE_LOADERS[0][0], 'production-templates')) # Check for serving static files # This uses CSS magic to hide this check when CSS is properly loaded. checks.append(( _('Admin static files'), False, 'production-admin-files', 'order-cell', )) return render(request, "admin/performance.html", { 'checks': checks, 'errors': get_configuration_errors() })
def performance(request): """ Shows performance tuning tips. """ checks = [] # Check for debug mode checks.append(( _('Debug mode'), not settings.DEBUG, 'production-debug', settings.DEBUG, )) # Check for domain configuration domain = Site.objects.get_current().domain checks.append(( _('Site domain'), check_domain(domain), 'production-site', domain, )) # Check database being used checks.append(( _('Database backend'), "sqlite" not in settings.DATABASES['default']['ENGINE'], 'production-database', settings.DATABASES['default']['ENGINE'], )) # Check configured admins checks.append(( _('Site administrator'), len(settings.ADMINS) > 0 or '*****@*****.**' in [x[1] for x in settings.ADMINS], 'production-admins', ', '.join([x[1] for x in settings.ADMINS]), )) # Check offloading indexing checks.append(( # Translators: Indexing is postponed to cron job _('Indexing offloading'), appsettings.OFFLOAD_INDEXING, 'production-indexing', appsettings.OFFLOAD_INDEXING )) if appsettings.OFFLOAD_INDEXING: if IndexUpdate.objects.count() < 20: index_updates = True elif IndexUpdate.objects.count() < 200: index_updates = None else: index_updates = False checks.append(( # Translators: Indexing is postponed to cron job _('Indexing offloading processing'), index_updates, 'production-indexing', IndexUpdate.objects.count(), )) # Check for sane caching caches = settings.CACHES['default']['BACKEND'].split('.')[-1] if caches in ['MemcachedCache', 'PyLibMCCache', 'DatabaseCache']: # We consider these good caches = True elif caches in ['DummyCache']: # This one is definitely bad caches = False else: # These might not be that bad caches = None checks.append(( _('Django caching'), caches, 'production-cache', settings.CACHES['default']['BACKEND'], )) # Avatar caching checks.append(( _('Avatar caching'), 'avatar' in settings.CACHES, 'production-cache-avatar', settings.CACHES['avatar']['BACKEND'] if 'avatar' in settings.CACHES else '', )) # Check email setup default_mails = ( 'root@localhost', 'webmaster@localhost', '*****@*****.**' ) checks.append(( _('Email addresses'), ( settings.SERVER_EMAIL not in default_mails and settings.DEFAULT_FROM_EMAIL not in default_mails ), 'production-email', ', '.join((settings.SERVER_EMAIL, settings.DEFAULT_FROM_EMAIL)), )) # libravatar library checks.append(( _('Federated avatar support'), HAS_LIBRAVATAR, 'production-avatar', HAS_LIBRAVATAR, )) # pyuca library checks.append(( _('pyuca library'), HAS_PYUCA, 'production-pyuca', HAS_PYUCA, )) # Cookie signing key checks.append(( _('Secret key'), settings.SECRET_KEY != settings_example.SECRET_KEY, 'production-secret', settings.SECRET_KEY, )) # Allowed hosts checks.append(( _('Allowed hosts'), len(settings.ALLOWED_HOSTS) > 0, 'production-hosts', ', '.join(settings.ALLOWED_HOSTS), )) loader = get_first_loader() # Cached template loader checks.append(( _('Cached template loader'), 'cached.Loader' in loader, 'production-templates', loader, )) # Check for serving static files checks.append(( _('Admin static files'), os.path.exists( os.path.join(settings.STATIC_ROOT, 'admin', 'js', 'core.js') ), 'production-admin-files', settings.STATIC_ROOT, )) context = admin_context(request) context['checks'] = checks context['errors'] = get_configuration_errors() return render( request, "admin/performance.html", context, )
def performance(request): """ Shows performance tuning tips. """ checks = [] # Check for debug mode checks.append(( _('Debug mode'), not settings.DEBUG, 'production-debug', )) # Check for domain configuration checks.append(( _('Site domain'), Site.objects.get_current().domain not in DEFAULT_DOMAINS, 'production-site', )) # Check database being used checks.append(( _('Database backend'), "sqlite" not in settings.DATABASES['default']['ENGINE'], 'production-database', )) # Check configured admins checks.append(( _('Site administrator'), len(settings.ADMINS) > 0, 'production-admins', )) # Check offloading indexing checks.append(( # Translators: Indexing is postponed to cron job _('Indexing offloading'), appsettings.OFFLOAD_INDEXING, 'production-indexing', )) # Check for sane caching caches = settings.CACHES['default']['BACKEND'].split('.')[-1] if caches in ['MemcachedCache', 'DatabaseCache']: # We consider these good caches = True elif caches in ['DummyCache']: # This one is definitely bad caches = False else: # These might not be that bad caches = None checks.append(( _('Django caching'), caches, 'production-cache', )) # Avatar caching checks.append(( _('Avatar caching'), 'avatar' in settings.CACHES, 'production-cache-avatar', )) # Check email setup default_mails = ( 'root@localhost', 'webmaster@localhost', '*****@*****.**' ) checks.append(( _('Email addresses'), ( settings.SERVER_EMAIL not in default_mails and settings.DEFAULT_FROM_EMAIL not in default_mails ), 'production-email', )) # libravatar library checks.append(( _('Federated avatar support'), HAS_LIBRAVATAR, 'production-avatar', )) # PyICU library checks.append(( _('PyICU library'), HAS_ICU, 'production-pyicu', )) # Cookie signing key checks.append(( _('Secret key'), settings.SECRET_KEY != settings_example.SECRET_KEY, 'production-secret', )) # Allowed hosts for Django 1.5 if django.VERSION > (1, 5): checks.append(( _('Allowed hosts'), len(settings.ALLOWED_HOSTS) > 0, 'production-hosts', )) # Writable home directory checks.append(( _('Home directory'), os.access(os.path.expanduser('~'), os.W_OK), 'production-home' )) # Cached template loader checks.append(( _('Cached template loader'), 'cached.Loader' in settings.TEMPLATE_LOADERS[0][0], 'production-templates' )) # Check for serving static files # This uses CSS magic to hide this check when CSS is properly loaded. checks.append(( _('Admin static files'), False, 'production-admin-files', 'order-cell', )) return render( request, "admin/performance.html", { 'checks': checks, 'errors': get_configuration_errors() } )
def performance(request): """ Shows performance tuning tips. """ checks = [] # Check for debug mode checks.append((_("Debug mode"), not settings.DEBUG, "production-debug")) # Check for domain configuration checks.append((_("Site domain"), Site.objects.get_current().domain not in DEFAULT_DOMAINS, "production-site")) # Check database being used checks.append( (_("Database backend"), "sqlite" not in settings.DATABASES["default"]["ENGINE"], "production-database") ) # Check configured admins checks.append( ( _("Site administrator"), len(settings.ADMINS) > 0 or "*****@*****.**" in [x[1] for x in settings.ADMINS], "production-admins", ) ) # Check offloading indexing checks.append( ( # Translators: Indexing is postponed to cron job _("Indexing offloading"), appsettings.OFFLOAD_INDEXING, "production-indexing", ) ) if appsettings.OFFLOAD_INDEXING: checks.append( ( # Translators: Indexing is postponed to cron job _("Indexing offloading processing"), IndexUpdate.objects.count() < 20, "production-indexing", ) ) # Check for sane caching caches = settings.CACHES["default"]["BACKEND"].split(".")[-1] if caches in ["MemcachedCache", "DatabaseCache"]: # We consider these good caches = True elif caches in ["DummyCache"]: # This one is definitely bad caches = False else: # These might not be that bad caches = None checks.append((_("Django caching"), caches, "production-cache")) # Avatar caching checks.append((_("Avatar caching"), "avatar" in settings.CACHES, "production-cache-avatar")) # Check email setup default_mails = ("root@localhost", "webmaster@localhost", "*****@*****.**") checks.append( ( _("Email addresses"), (settings.SERVER_EMAIL not in default_mails and settings.DEFAULT_FROM_EMAIL not in default_mails), "production-email", ) ) # libravatar library checks.append((_("Federated avatar support"), HAS_LIBRAVATAR, "production-avatar")) # pyuca library checks.append((_("pyuca library"), HAS_PYUCA, "production-pyuca")) # Cookie signing key checks.append((_("Secret key"), settings.SECRET_KEY != settings_example.SECRET_KEY, "production-secret")) # Allowed hosts checks.append((_("Allowed hosts"), len(settings.ALLOWED_HOSTS) > 0, "production-hosts")) # Cached template loader checks.append( (_("Cached template loader"), "cached.Loader" in settings.TEMPLATE_LOADERS[0][0], "production-templates") ) # Check for serving static files # This uses CSS magic to hide this check when CSS is properly loaded. checks.append((_("Admin static files"), False, "production-admin-files", "order-cell")) return render(request, "admin/performance.html", {"checks": checks, "errors": get_configuration_errors()})