settings.py 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. """
  2. Django settings for barcode project.
  3. Generated by 'django-admin startproject' using Django 2.0.3.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/2.0/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/2.0/ref/settings/
  8. """
  9. import os
  10. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  11. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  12. # Quick-start development settings - unsuitable for production
  13. # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
  14. # SECURITY WARNING: keep the secret key used in production secret!
  15. SECRET_KEY = '-#5(dek!ea$q1^_skd^0@=m-5$mmp91y#l!h#n11g21#prk-v7'
  16. # SECURITY WARNING: don't run with debug turned on in production!
  17. DEBUG = False
  18. ALLOWED_HOSTS = [
  19. '*',
  20. 'app-test.trashiskey.com',
  21. ]
  22. # Application definition
  23. INSTALLED_APPS = [
  24. 'django.contrib.admin',
  25. 'django.contrib.auth',
  26. 'django.contrib.contenttypes',
  27. 'django.contrib.sessions',
  28. 'django.contrib.messages',
  29. 'django.contrib.staticfiles',
  30. 'rest_framework',
  31. 'rest_framework.authtoken',
  32. 'rest_auth',
  33. 'scanapp',
  34. 'language',
  35. 'frontendtexts',
  36. 'myauth',
  37. 'django.contrib.sites',
  38. 'allauth',
  39. 'allauth.account',
  40. 'allauth.socialaccount.providers.google',
  41. 'rest_auth.registration',
  42. 'corsheaders',
  43. 'oauth2_provider',
  44. #'social_django',
  45. #'rest_framework_social_oauth2',
  46. ]
  47. MIDDLEWARE = [
  48. 'django.middleware.security.SecurityMiddleware',
  49. 'django.contrib.sessions.middleware.SessionMiddleware',
  50. 'django.middleware.common.CommonMiddleware',
  51. #'django.middleware.csrf.CsrfViewMiddleware',
  52. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  53. 'django.contrib.messages.middleware.MessageMiddleware',
  54. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  55. 'scanapp.middlewares.ActivityMiddleware',
  56. 'corsheaders.middleware.CorsMiddleware',
  57. ]
  58. ROOT_URLCONF = 'barcode.urls'
  59. CORS_ORIGIN_ALLOW_ALL = True
  60. TEMPLATES = [
  61. {
  62. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  63. 'DIRS': [],
  64. 'APP_DIRS': True,
  65. 'OPTIONS': {
  66. 'context_processors': [
  67. 'django.template.context_processors.debug',
  68. 'django.template.context_processors.request',
  69. 'django.contrib.auth.context_processors.auth',
  70. 'django.contrib.messages.context_processors.messages',
  71. #'social_django.context_processors.backends',
  72. #'social_django.context_processors.login_redirect',
  73. ],
  74. },
  75. },
  76. ]
  77. SOCIAL_AUTH_STORAGE = 'scanapp.models.User'
  78. SOCIAL_AUTH_ADMIN_USER_SEARCH_FIELDS = ['user_id', 'social', 'token']
  79. LOGIN_URL = 'login'
  80. #LOGIN_REDIRECT_URL = 'home'
  81. WSGI_APPLICATION = 'barcode.wsgi.application'
  82. SITE_ID = 2
  83. # Database
  84. # https://docs.djangoproject.com/en/2.0/ref/settings/#databases
  85. DATABASES = {
  86. 'default': {
  87. 'ENGINE': 'django.db.backends.sqlite3',
  88. 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
  89. }
  90. }
  91. REST_FRAMEWORK = {
  92. 'DEFAULT_AUTHENTICATION_CLASSES': (
  93. 'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
  94. 'rest_framework.authentication.TokenAuthentication',
  95. 'rest_framework.authentication.BasicAuthentication',
  96. 'django.contrib.auth.backends.ModelBackend',
  97. #'scanapp.myauth.TokenAuth',
  98. #'rest_framework_social_oauth2.authentication.SocialAuthentication',
  99. #'oauth2_provider.contrib.rest_framework.OAuth2Authentication'
  100. ),
  101. 'DEFAULT_PERMISSION_CLASS' : (
  102. #'rest_framework.permissions.IsAuthenticated',
  103. )
  104. }
  105. AUTHENTICATION_BACKENDS = (
  106. 'allauth.account.auth_backends.AuthenticationBackend',
  107. #'rest_framework_social_oauth2.backends.DjangoOAuth2',
  108. #'django.contrib.auth.backends.ModelBackend',
  109. #'social_core.backends.google.GoogleOAuth2',
  110. )
  111. SOCIALACCOUNT_PROVIDERS = {
  112. 'google': {
  113. 'SCOPE': [
  114. 'profile',
  115. 'email',
  116. ],
  117. 'AUTH_PARAMS': {
  118. 'access_type': 'online',
  119. }
  120. }
  121. }
  122. # Password validation
  123. # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
  124. AUTH_PASSWORD_VALIDATORS = [
  125. {
  126. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  127. },
  128. {
  129. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  130. },
  131. {
  132. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  133. },
  134. {
  135. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  136. },
  137. ]
  138. # Internationalization
  139. # https://docs.djangoproject.com/en/2.0/topics/i18n/
  140. LANGUAGE_CODE = 'en-us'
  141. TIME_ZONE = 'UTC'
  142. USE_I18N = True
  143. USE_L10N = True
  144. USE_TZ = True
  145. # Static files (CSS, JavaScript, Images)
  146. # https://docs.djangoproject.com/en/2.0/howto/static-files/
  147. STATIC_URL = '/static/'
  148. # STATIC_ROOT = os.path.join(BASE_DIR,'static/')
  149. STATICFILES_DIRS = [
  150. os.path.join(BASE_DIR,'static/')
  151. ]