· 8 years ago · Jan 01, 2018, 07:08 AM
1from django.conf.urls import url
2from django.contrib.auth.views import login, logout_then_login
3from django.urls import reverse_lazy
4
5from . import views
6from django.contrib.auth import views as auth_views
7
8app_name = 'invo'
9urlpatterns = [
10
11 # Login Logout
12 url(r'^login/$', login,
13 {'template_name': 'invo/login.html'},
14 name='login'),
15 url(r'^logout/$', logout_then_login, name='logout'),
16
17]
18
19# the upstream component nginx needs to connect to
20upstream django {
21 # server unix:///path/to/your/mysite/mysite.sock; # for a file socket
22 server 127.0.0.1:8001; # for a web port socket (we'll use this first)
23}
24# configuration of the server
25server {
26 # the port your site will be served on
27 listen 443 ssl;
28 ssl_certificate /etc/letsencrypt/live/tekis.biz/fullchain.pem;
29 ssl_certificate_key /etc/letsencrypt/live/tekis.biz/privkey.pem;
30 # the domain name it will serve for
31 server_name tekis.biz; # substitute your machine's IP address or FQDN
32 charset utf-8;
33 # max upload size
34 client_max_body_size 75M; # adjust to taste
35 location /static {
36 alias /home/teranori/invoice/invo/static/; # your Django project's static files - amend as required
37 }
38 # Finally, send all non-media requests to the Django server.
39 location / {
40 uwsgi_pass django;
41 include /home/teranori/invoice/uwsgi_params; # the uwsgi_params file you installed
42 proxy_set_header Host $http_host;
43 proxy_set_header X-Real-IP $remote_addr;
44 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
45 }
46}
47
48import os
49
50# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
51from os.path import dirname, abspath
52
53from django.contrib.sites.shortcuts import get_current_site
54
55BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
56
57# Quick-start development settings - unsuitable for production
58# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
59
60# SECURITY WARNING: keep the secret key used in production secret!
61SECRET_KEY = 'xxx'
62
63# SECURITY WARNING: don't run with debug turned on in production!
64DEBUG = True
65# DEBUG = False
66
67ALLOWED_HOSTS = ['tekis.biz','104.154.150.16', '127.0.0.1', 'localhost']
68
69# Application definition
70
71INSTALLED_APPS = [
72 'invo.apps.InvoConfig',
73 'django.contrib.admin',
74 'django.contrib.auth',
75 'django.contrib.contenttypes',
76 'django.contrib.sessions',
77 'django.contrib.messages',
78 'django.contrib.staticfiles',
79 'django_extensions',
80]
81
82MIDDLEWARE = [
83 'django.middleware.security.SecurityMiddleware',
84 'django.contrib.sessions.middleware.SessionMiddleware',
85 'django.middleware.common.CommonMiddleware',
86 'django.middleware.csrf.CsrfViewMiddleware',
87 'django.contrib.auth.middleware.AuthenticationMiddleware',
88 'django.contrib.messages.middleware.MessageMiddleware',
89 'django.middleware.clickjacking.XFrameOptionsMiddleware',
90]
91
92ROOT_URLCONF = 'mysite.urls'
93
94
95WSGI_APPLICATION = 'mysite.wsgi.application'
96
97
98
99# [START dbconfig]
100DATABASES = {
101 'default': {
102 'ENGINE': 'django.db.backends.postgresql',
103 'NAME': 'xxx',
104 'USER': 'xxx',
105 'PASSWORD': 'xxx',
106 'HOST': 'localhost',
107 'PORT': '5432',
108 }
109}
110
111
112
113
114
115# Password validation
116# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
117
118AUTH_PASSWORD_VALIDATORS = [
119 {
120 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
121 },
122 {
123 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
124 },
125 {
126 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
127 },
128 {
129 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
130 },
131]
132
133# Internationalization
134# https://docs.djangoproject.com/en/1.11/topics/i18n/
135
136LANGUAGE_CODE = 'ja'
137
138TIME_ZONE = 'Asia/Tokyo'
139
140USE_I18N = True
141
142USE_L10N = True
143
144USE_TZ = True
145
146STATIC_URL = BASE_DIR+'/invo/static/'
147STATIC_URL = 'https://tekis.biz/static/'
148
149PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
150STATICFILES_FINDERS = (
151 'django.contrib.staticfiles.finders.FileSystemFinder',
152 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
153 # 'django.contrib.staticfiles.finders.DefaultStorageFinder',
154)
155STATICFILES_DIRS = (
156 os.path.join(BASE_DIR, 'invo/static/'),
157)
158
159# DJANGO_ROOT = dirname(dirname(abspath(__file__)))
160# PROJECT_ROOT = dirname(DJANGO_ROOT)
161STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
162
163MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
164MEDIA_URL = '/media/'
165
166AUTH_USER_MODEL = 'invo.InvoUser'
167
168# AUTHENTICATION_BACKENDS = [
169# 'invo.backends.EmailOrUsernameModelBackend'
170# ]
171AUTHENTICATION_BACKENDS = (
172 'django.contrib.auth.backends.ModelBackend',
173 'django.contrib.auth.backends.ModelBackend',
174)
175
176AUTH_USER_EMAIL_UNIQUE = True
177
178# SILENCED: Username is not unique
179SILENCED_SYSTEM_CHECKS = ["auth.W004"]
180
181LOGIN_REDIRECT_URL = '/'
182LOGIN_URL = "/login/"
183
184
185TEMPLATES = [
186 {
187 'BACKEND': 'django.template.backends.django.DjangoTemplates',
188 'DIRS': [os.path.join(STATIC_URL, 'templates')],
189 'DIRS': ['static/templates/'],
190 'APP_DIRS': True,
191 'OPTIONS': {
192 'context_processors': [
193 'social_django.context_processors.backends',
194 'social_django.context_processors.login_redirect',
195 'django.template.context_processors.debug',
196 'django.template.context_processors.request',
197 'django.contrib.auth.context_processors.auth',
198 'django.contrib.messages.context_processors.messages',
199 # 'social.apps.django_app.context_processors.backends',
200 # 'social.apps.django_app.context_processors.login_redirect',
201 ],
202 },
203 },
204]
205
206TEMPLATE_LOADERS = (
207 'django.template.loaders.filesystem.load_template_source',
208 'ragendja.template.app_prefixed_loader',
209 'django.template.loaders.app_directories.load_template_source',
210)
211
212# HTPPS/SSL
213SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
214SECURE_SSL_REDIRECT = True
215SESSION_COOKIE_SECURE = True
216CSRF_COOKIE_SECURE = True