Open
Description
This is my python packages:
Django==1.10.1
django-braces==1.9.0
django-cors-middleware==1.3.1
django-devserver==0.8.0
django-oauth-toolkit==0.10.0
djangorestframework==3.4.6
drfdocs==0.0.11
guppy==0.1.10
line-profiler==1.0
Markdown==2.6.6
oauthlib==1.0.3
Pillow==3.3.1
psycopg2==2.6.2
requests==2.11.1
six==1.10.0
sqlparse==0.2.1
Werkzeug==0.11.11
I configured multiple settings file which results to:
settings
- init.py
- base.py
- local.py
This is my base.py
"""
Django settings for xxx_api project.
Generated by 'django-admin startproject' using Django 1.10.1.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
# BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = ')@kqdcf)0l@l37m@r(_ng3-loe%5j@0g!-h@uju0qek@%m&r7l'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MANUALLY_BUILT_APPS = [
'api',
'core',
'core.conversations',
'core.reports',
'core.groups',
'core.accounts',
'system_admin',
'assessor',
'workplace_supervisor',
'students',
'functional_tests',
]
INSTALLED_APPS += MANUALLY_BUILT_APPS
THIRD_PARTY_APPS = [
'corsheaders',
'rest_framework', # Restful API library for Django
'oauth2_provider', # Oauth2 library especially made for django with django rest framework integration
'rest_framework_docs', # Library for creating API Documentation
'markdown',
]
INSTALLED_APPS += THIRD_PARTY_APPS
MIDDLEWARE_CLASSES = [
'corsheaders.middleware.CorsMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
]
ROOT_URLCONF = 'xxx_api.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'xxx_api.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": "xxx",
"USER": "xxx",
"PASSWORD": "xxxxxxxx",
"HOST": "xxx",
"PORT": "5432"
}
}
if os.environ.get('BITBUCKETPIPELINES', '0') == '1':
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": "xxx",
"USER": "root",
"PASSWORD": "pass1234",
"HOST": "127.0.0.1",
"PORT": "5432"
}
}
# Password validation
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = False # Set to False to import optimizations
USE_L10N = True
USE_TZ = True
# Source: fideloper.com/api-etag-conditional-get
# Use "If-None-Match" header with Etag
# Work with client on this carefully
USE_ETAGS = True # For caching mechanism
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
# START Django Rest Framework settings
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
),
'DEFAULT_AUTHENTICATION_CLASSES': (
'oauth2_provider.ext.rest_framework.OAuth2Authentication',
),
# Disables the Admin UI of the Django Rest Framework
# Source: http://stackoverflow.com/questions/11898065/how-to-disable-admin-style-browsable-interface-of-django-rest-framework
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
)
}
# END Django Rest Framework settings
CORS_ORIGIN_ALLOW_ALL = True
OAUTH2_PROVIDER = {
"ACCESS_TOKEN_EXPIRE_SECONDS": 7776000 # 3 months
}
This is my local.py
from .base import *
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'xxx',
'USER': 'deanarmada',
'PASSWORD': 'd3@narmada13',
'HOST': 'localhost',
'PORT': '',
}
}
LOCAL_APPS = [
'devserver',
]
INSTALLED_APPS += LOCAL_APPS
LOCAL_MIDDLEWARES = [
'devserver.middleware.DevServerMiddleware',
]
MIDDLEWARE_CLASSES += LOCAL_MIDDLEWARES
# Extra DEVSERVER logging
DEVSERVER_MODULES = (
'devserver.modules.sql.SQLRealTimeModule',
'devserver.modules.sql.SQLSummaryModule',
'devserver.modules.profile.ProfileSummaryModule',
# Modules not enabled by default
'devserver.modules.ajax.AjaxDumpModule',
'devserver.modules.profile.MemoryUseModule',
'devserver.modules.cache.CacheSummaryModule',
'devserver.modules.profile.LineProfilerModule',
)
DEVSERVER_AUTO_PROFILE = True # profiles all views without the need of function decorator
It is just fine when I do a runserver but when I do a request this is what shows in the log:
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 1364, in isEnabledFor
return level >= self.getEffectiveLevel()
RuntimeError: maximum recursion depth exceeded
[sql] SELECT ...
FROM "auth_user"
WHERE "auth_user"."username" = dean LIMIT 21
[sql] SELECT ...
FROM "auth_user" LIMIT 21
[sql] SELECT ...
FROM "auth_user"
WHERE "auth_user"."username" = dean LIMIT 21
[sql] SELECT ...
FROM "auth_user"
WHERE "auth_user"."username" = dean LIMIT 21
[sql] SELECT ...
FROM "auth_user"
WHERE "auth_user"."username" = dean LIMIT 21
[sql] (82914ms) 5699 queries with 5698 duplicates
[profile] Total time to render was 2.42s
[profile] 10.6 MB allocated, 44.6 KB deallocated, heap size is 30.5 MB
[cache] 0 calls made with a 100% hit percentage (0 misses)
[profile] Timer unit: 1e-06 s
Total time: 0.032768 s
File: /Users/deanarmada/.virtualenvs/api/lib/python2.7/site-packages/django/views/decorators/csrf.py
Function: wrapped_view at line 57
Line # Hits Time Per Hit % Time Line Contents
==============================================================
57 def wrapped_view(*args, **kwargs):
58 1 32768 32768.0 100.0 return view_func(*args, **kwargs)
Metadata
Metadata
Assignees
Labels
No labels