|
| 1 | +from pathlib import Path |
| 2 | +import os |
| 3 | + |
| 4 | + |
| 5 | +BASE_DIR = Path(__file__).resolve().parent.parent |
| 6 | + |
| 7 | +SECRET_KEY = 'django-insecure-o+f#qyg$c$m=fk=j1+05vn@_m&tyy&++ea#ak(!!g(ek*#$y0!' |
| 8 | + |
| 9 | +DEBUG = True |
| 10 | + |
| 11 | +ALLOWED_HOSTS = [] |
| 12 | + |
| 13 | +INSTALLED_APPS = [ |
| 14 | + 'daphne', |
| 15 | + 'channels', |
| 16 | + 'django.contrib.admin', |
| 17 | + 'django.contrib.auth', |
| 18 | + 'django.contrib.contenttypes', |
| 19 | + 'django.contrib.sessions', |
| 20 | + 'django.contrib.messages', |
| 21 | + 'django.contrib.staticfiles', |
| 22 | + 'django.contrib.sites', |
| 23 | + 'rest_framework', |
| 24 | + 'django_cleanup', |
| 25 | + 'allauth', |
| 26 | + 'allauth.account', |
| 27 | + 'allauth.socialaccount', |
| 28 | + 'allauth.socialaccount.providers.google', |
| 29 | + # My Apps |
| 30 | + 'chat_app.apps.ChatAppConfig', |
| 31 | + 'account_app.apps.AccountAppConfig', |
| 32 | +] |
| 33 | + |
| 34 | +MIDDLEWARE = [ |
| 35 | + 'django.middleware.security.SecurityMiddleware', |
| 36 | + 'django.contrib.sessions.middleware.SessionMiddleware', |
| 37 | + 'django.middleware.common.CommonMiddleware', |
| 38 | + 'django.middleware.csrf.CsrfViewMiddleware', |
| 39 | + 'django.contrib.auth.middleware.AuthenticationMiddleware', |
| 40 | + 'django.contrib.messages.middleware.MessageMiddleware', |
| 41 | + 'django.middleware.clickjacking.XFrameOptionsMiddleware', |
| 42 | +] |
| 43 | + |
| 44 | +ROOT_URLCONF = 'ChatApp.urls' |
| 45 | + |
| 46 | +TEMPLATES = [ |
| 47 | + { |
| 48 | + 'BACKEND': 'django.template.backends.django.DjangoTemplates', |
| 49 | + 'DIRS': [BASE_DIR, 'templates'], |
| 50 | + 'APP_DIRS': True, |
| 51 | + 'OPTIONS': { |
| 52 | + 'context_processors': [ |
| 53 | + 'django.template.context_processors.debug', |
| 54 | + 'django.template.context_processors.request', |
| 55 | + 'django.contrib.auth.context_processors.auth', |
| 56 | + 'django.contrib.messages.context_processors.messages', |
| 57 | + ], |
| 58 | + }, |
| 59 | + }, |
| 60 | +] |
| 61 | + |
| 62 | +WSGI_APPLICATION = 'ChatApp.wsgi.application' |
| 63 | +ASGI_APPLICATION = 'ChatApp.asgi.application' |
| 64 | + |
| 65 | +DATABASES = { |
| 66 | + 'default': { |
| 67 | + 'ENGINE': 'django.db.backends.sqlite3', |
| 68 | + 'NAME': BASE_DIR / 'db.sqlite3', |
| 69 | + } |
| 70 | +} |
| 71 | + |
| 72 | +AUTH_PASSWORD_VALIDATORS = [ |
| 73 | + { |
| 74 | + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', |
| 75 | + }, |
| 76 | + { |
| 77 | + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', |
| 78 | + }, |
| 79 | + { |
| 80 | + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', |
| 81 | + }, |
| 82 | + { |
| 83 | + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', |
| 84 | + }, |
| 85 | +] |
| 86 | + |
| 87 | +AUTH_USER_MODEL = "account_app.User" |
| 88 | + |
| 89 | +LANGUAGE_CODE = 'en-us' |
| 90 | +TIME_ZONE = 'Asia/Tehran' |
| 91 | +USE_I18N = True |
| 92 | +USE_TZ = True |
| 93 | + |
| 94 | +STATIC_URL = 'static/' |
| 95 | +STATICFILES_DIRS = [os.path.join(BASE_DIR, 'assets')] |
| 96 | +STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') |
| 97 | +MEDIA_URL = 'media/' |
| 98 | +MEDIA_ROOT = os.path.join(BASE_DIR, 'media') |
| 99 | + |
| 100 | +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' |
| 101 | + |
| 102 | +# Email Configs--------------------------------------------- |
| 103 | +EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' |
| 104 | +EMAIL_HOST = 'smtp.gmail.com' |
| 105 | +EMAIL_USE_TLS = True |
| 106 | +EMAIL_PORT = 587 |
| 107 | +EMAIL_HOST_USER = '' |
| 108 | +EMAIL_HOST_PASSWORD = '' |
| 109 | + |
| 110 | +CHANNEL_LAYERS = { |
| 111 | + "default": { |
| 112 | + "BACKEND": "channels_redis.core.RedisChannelLayer", |
| 113 | + "CONFIG": { |
| 114 | + "hosts": [("localhost", 6379)], |
| 115 | + }, |
| 116 | + }, |
| 117 | +} |
| 118 | + |
| 119 | +AUTHENTICATION_BACKENDS = [ |
| 120 | + 'django.contrib.auth.backends.ModelBackend', |
| 121 | + 'allauth.account.auth_backends.AuthenticationBackend' |
| 122 | +] |
| 123 | + |
| 124 | +SOCIALACCOUNT_PROVIDERS = { |
| 125 | + 'google': { |
| 126 | + 'SCOPE': [ |
| 127 | + 'profile', |
| 128 | + 'email', |
| 129 | + ], |
| 130 | + 'AUTH_PARAMS': { |
| 131 | + 'access_type': 'online', |
| 132 | + } |
| 133 | + } |
| 134 | +} |
| 135 | + |
| 136 | +SITE_ID = 1 |
| 137 | +LOGIN_REDIRECT_URL = '/' |
| 138 | + |
| 139 | +# Additional configuration settings |
| 140 | +SOCIALACCOUNT_QUERY_EMAIL = True |
| 141 | +ACCOUNT_LOGOUT_ON_GET = True |
| 142 | +ACCOUNT_UNIQUE_EMAIL = True |
| 143 | +ACCOUNT_EMAIL_REQUIRED = True |
| 144 | + |
| 145 | + |
| 146 | +# Celery Configuration |
| 147 | +CELERY_TIMEZONE = "Asia/Tehran" |
| 148 | +CELERY_ENABLE_UTC = True |
| 149 | +CELERY_BROKER_URL = 'pyamqp://guest@localhost:5672' |
| 150 | +CELERY_RESULT_BACKEND = 'redis://localhost:6379' |
0 commit comments