· 5 years ago · Sep 24, 2020, 03:02 PM
1"""
2Django settings for yatube project.
3
4Generated by 'django-admin startproject' using Django 2.2.6.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/2.2/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/2.2/ref/settings/
11"""
12
13import os
14
15# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17
18
19# Quick-start development settings - unsuitable for production
20# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
21
22# SECURITY WARNING: keep the secret key used in production secret!
23SECRET_KEY = 'm%(5u7nv9j2%@3xb%#c3p-$9&0$kq$j6l@9+@ogairu48a+dy+'
24
25# SECURITY WARNING: don't run with debug turned on in production!
26DEBUG = True
27
28ALLOWED_HOSTS = ['*']
29
30
31# Application definition
32
33INSTALLED_APPS = [
34 'django.contrib.admin',
35 'django.contrib.auth',
36 'django.contrib.contenttypes',
37 'django.contrib.sessions',
38 'django.contrib.messages',
39 'django.contrib.staticfiles',
40 'posts',
41 'rest_framework',
42 'rest_framework.authtoken',
43 'corsheaders',
44]
45
46REST_FRAMEWORK = {
47 'DEFAULT_PERMISSION_CLASSES': [
48 'rest_framework.permissions.IsAuthenticated',
49 ],
50
51 'DEFAULT_AUTHENTICATION_CLASSES': [
52 'rest_framework.authentication.TokenAuthentication',
53 ]
54}
55
56MIDDLEWARE = [
57 'django.middleware.security.SecurityMiddleware',
58 'django.contrib.sessions.middleware.SessionMiddleware',
59 'corsheaders.middleware.CorsMiddleware',
60 'django.middleware.common.CommonMiddleware',
61 'django.middleware.csrf.CsrfViewMiddleware',
62 'django.contrib.auth.middleware.AuthenticationMiddleware',
63 'django.contrib.messages.middleware.MessageMiddleware',
64 'django.middleware.clickjacking.XFrameOptionsMiddleware',
65]
66
67CORS_ORIGIN_ALLOW_ALL = True
68CORS_URLS_REGEX = r'^/api/.*$'
69
70ROOT_URLCONF = 'yatube_api.urls'
71TEMPLATES_DIR = os.path.join(BASE_DIR, "templates")
72TEMPLATES = [
73 {
74 'BACKEND': 'django.template.backends.django.DjangoTemplates',
75 'DIRS': [TEMPLATES_DIR],
76 'APP_DIRS': True,
77 'OPTIONS': {
78 'context_processors': [
79 'django.template.context_processors.debug',
80 'django.template.context_processors.request',
81 'django.contrib.auth.context_processors.auth',
82 'django.contrib.messages.context_processors.messages',
83 ],
84 },
85 },
86]
87
88WSGI_APPLICATION = 'yatube_api.wsgi.application'
89
90
91# Database
92# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
93
94DATABASES = {
95 'default': {
96 'ENGINE': 'django.db.backends.sqlite3',
97 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
98 }
99}
100
101
102# Password validation
103# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
104
105AUTH_PASSWORD_VALIDATORS = [
106 {
107 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
108 },
109 {
110 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
111 },
112 {
113 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
114 },
115 {
116 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
117 },
118]
119
120# Internationalization
121# https://docs.djangoproject.com/en/2.2/topics/i18n/
122
123LANGUAGE_CODE = 'ru'
124
125TIME_ZONE = 'UTC'
126
127USE_I18N = True
128
129USE_L10N = True
130
131USE_TZ = True
132
133
134# Static files (CSS, JavaScript, Images)
135# https://docs.djangoproject.com/en/2.2/howto/static-files/
136
137STATIC_URL = '/static/'
138
139MEDIA_URL = "/media/"
140MEDIA_ROOT = os.path.join(BASE_DIR, "media")
141