· 9 years ago · Nov 20, 2016, 06:52 AM
1"""
2Django settings for backend project.
3
4Generated by 'django-admin startproject' using Django 1.10.3.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/1.10/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/1.10/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/1.10/howto/deployment/checklist/
22
23# SECURITY WARNING: keep the secret key used in production secret!
24SECRET_KEY = '<verysecret>'
25
26# SECURITY WARNING: don't run with debug turned on in production!
27DEBUG = True
28
29ALLOWED_HOSTS = ['192.168.1.54']
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 'backend.api',
43 'corsheaders'
44]
45
46MIDDLEWARE = [
47 'django.middleware.security.SecurityMiddleware',
48 'django.contrib.sessions.middleware.SessionMiddleware',
49 'django.middleware.common.CommonMiddleware',
50# 'django.middleware.csrf.CsrfViewMiddleware',
51 'django.contrib.auth.middleware.AuthenticationMiddleware',
52 'django.contrib.messages.middleware.MessageMiddleware',
53 'django.middleware.clickjacking.XFrameOptionsMiddleware',
54 'corsheaders.middleware.CorsMiddleware',
55 'django.middleware.common.CommonMiddleware',
56]
57
58ROOT_URLCONF = 'backend.api.urls'
59
60TEMPLATES = [
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 ],
72 },
73 },
74]
75
76WSGI_APPLICATION = 'backend.wsgi.application'
77
78
79# Database
80# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
81
82DATABASES = {
83 'default': {
84 'ENGINE': 'django.db.backends.mysql',
85 'NAME': 'django',
86 'USER': 'root',
87 'PASSWORD': 'root',
88 'HOST': 'localhost', # Or an IP Address that your DB is hosted on
89 'PORT': '3306',
90 }
91}
92
93
94
95# Password validation
96# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
97
98AUTH_PASSWORD_VALIDATORS = [
99 {
100 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
101 },
102 {
103 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
104 },
105 {
106 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
107 },
108 {
109 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
110 },
111]
112
113
114# Internationalization
115# https://docs.djangoproject.com/en/1.10/topics/i18n/
116
117LANGUAGE_CODE = 'en-us'
118
119TIME_ZONE = 'UTC'
120
121USE_I18N = True
122
123USE_L10N = True
124
125USE_TZ = True
126
127
128# Static files (CSS, JavaScript, Images)
129# https://docs.djangoproject.com/en/1.10/howto/static-files/
130
131STATIC_URL = '/static/'
132
133CORS_ORIGIN_ALLOW_ALL = True
134
135REST_FRAMEWORK = {
136 'DEFAULT_PERMISSION_CLASSES': (
137 'rest_framework.permissions.AllowAny',
138 ),
139 'DEFAULT_AUTHENTICATION_CLASSES': (
140 'rest_framework.authentication.TokenAuthentication',
141 'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
142 ),
143}
144
145JWT_AUTH = {
146 'JWT_EXPIRATION_DELTA': datetime.timedelta(seconds=60*60),
147 'JWT_ALLOW_REFRESH': True,
148}