· 7 years ago · Jun 08, 2018, 11:02 PM
1"""
2Django settings for authproject project.
3
4Generated by 'django-admin startproject' using Django 2.0.6.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/2.0/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/2.0/ref/settings/
11"""
12
13import os
14import datetime
15
16# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
17BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
18
19
20# Quick-start development settings - unsuitable for production
21# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
22
23# SECURITY WARNING: keep the secret key used in production secret!
24SECRET_KEY = 'km)w$e#p9%#y1rln4v_mi9w$o9@^fz_z_i&i3!nf3x=#r2q7fx'
25
26# SECURITY WARNING: don't run with debug turned on in production!
27DEBUG = False #
28
29ALLOWED_HOSTS = ['localhost', '127.0.0.1', 'www.mysite.com'] #
30
31
32# Application definition
33
34INSTALLED_APPS = [
35 'django.contrib.admin',
36 'django.contrib.auth',
37 'django.contrib.contenttypes',
38 'django.contrib.sessions',
39 'django.contrib.messages',
40 'django.contrib.staticfiles',
41 'rest_framework', #
42 'rest_auth', #
43 'django.contrib.sites', #
44 'allauth', #
45 'allauth.account', #
46 'rest_auth.registration', #
47 'app', #
48]
49
50MIDDLEWARE = [
51 'django.middleware.security.SecurityMiddleware',
52 'django.contrib.sessions.middleware.SessionMiddleware',
53 'django.middleware.common.CommonMiddleware',
54 'django.middleware.csrf.CsrfViewMiddleware',
55 'django.contrib.auth.middleware.AuthenticationMiddleware',
56 'django.contrib.messages.middleware.MessageMiddleware',
57 'django.middleware.clickjacking.XFrameOptionsMiddleware',
58]
59
60ROOT_URLCONF = 'authproject.urls'
61
62TEMPLATES = [
63 {
64 'BACKEND': 'django.template.backends.django.DjangoTemplates',
65 'DIRS': [],
66 'APP_DIRS': True,
67 'OPTIONS': {
68 'context_processors': [
69 'django.template.context_processors.debug',
70 'django.template.context_processors.request',
71 'django.contrib.auth.context_processors.auth',
72 'django.contrib.messages.context_processors.messages',
73 ],
74 },
75 },
76]
77
78WSGI_APPLICATION = 'authproject.wsgi.application'
79
80
81# Database
82# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
83
84DATABASES = {
85 'default': {
86 'ENGINE': 'django.db.backends.sqlite3',
87 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
88 }
89}
90
91
92# Password validation
93# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
94
95AUTH_PASSWORD_VALIDATORS = [
96 {
97 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
98 },
99 {
100 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
101 },
102 {
103 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
104 },
105 {
106 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
107 },
108]
109
110
111# Internationalization
112# https://docs.djangoproject.com/en/2.0/topics/i18n/
113
114LANGUAGE_CODE = 'en-us'
115
116TIME_ZONE = 'UTC'
117
118USE_I18N = True
119
120USE_L10N = True
121
122USE_TZ = True
123
124
125# Static files (CSS, JavaScript, Images)
126# https://docs.djangoproject.com/en/2.0/howto/static-files/
127
128STATIC_URL = '/static/'
129
130# ---------------------------------------------------------------------------------------------
131# Configure the JWTs to expire after 1 hour, and allow users to refresh near-expiration tokens
132JWT_AUTH = {
133 'JWT_EXPIRATION_DELTA': datetime.timedelta(hours=1),
134 'JWT_ALLOW_REFRESH': True,
135}
136
137# Make JWT Auth the default authentication mechanism for Django
138REST_FRAMEWORK = {
139 'DEFAULT_AUTHENTICATION_CLASSES': (
140 'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
141 ),
142}
143
144# Enables django-rest-auth to use JWT tokens instead of regular tokens.
145REST_USE_JWT = True
146
147SITE_ID = 1
148# ---------------------------------------------------------------------------------------------