· 9 years ago · Oct 13, 2016, 07:12 PM
1EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
2DEFAULT_FROM_EMAIL = 'site@gmail.com'
3EMAIL_USE_TLS = True
4EMAIL_HOST = 'smtp.gmail.com'
5EMAIL_HOST_USER = 'site@gmail.com'
6EMAIL_HOST_PASSWORD = '123456'
7EMAIL_PORT = 587
8
9xx.xx.xxx.xxx - - [13/Oct/2016:20:15:59 +0300] "GET / HTTP/1.1" 200 12659 "http://eximo.fabro.com.ua/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.27$3.0.2785.143 Safari/537.36"
10xx.xx.xxx.xxx - - [13/Oct/2016:20:17:05 +0300] "POST /order/ HTTP/1.1" 500 38 "http://eximo.fabro.com.ua/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.$me/53.0.2785.143 Safari/537.36"
11
12Ubuntu 14.04.5 LTS
13
14nginx version: nginx/1.4.6 (Ubuntu)
15built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
16TLS SNI support enabled
17configure arguments: --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module
18
192.0.13.1
20
21[uwsgi]
22project = site
23base = /home/site
24
25chdir = %(base)/site/%(project)
26home = /env/site
27module = project.wsgi:application
28
29master = true
30processes = 5
31
32pidfile = %(base)/site/%(project)/site.pid
33
34socket = %(base)/site/%(project)/site.sock
35chmod-socket = 664
36vacuum = true
37
38server {
39 listen *:80;
40 listen [::]:80;
41 server_name www.site.com.ua;
42 rewrite ^(.*)$ http://site.com.ua$1 permanent;
43}
44
45server {
46 listen *:80;
47 listen [::]:80;
48 server_name site.com.ua;
49
50
51 location = /favicon.ico { access_log off; log_not_found off; }
52
53 location /static/ {
54 root /home/site/site/site/project;
55 access_log off;
56 expires 3w;
57 # add_header Cache-Control "max-age=1209600";
58 add_header Cache-Control public;
59 }
60
61 location /media/ {
62 root /home/site/site/site/project;
63 access_log off;
64 expires 12w;
65 # add_header Cache-Control "max-age=5258000";
66 add_header Cache-Control public;
67 }
68
69 location / {
70 include uwsgi_params;
71 uwsgi_pass unix:/home/site/site/site/site.sock;
72 }
73}
74
75gzip on;
76gzip_disable "msie6";
77
78gzip_vary on;
79gzip_proxied any;
80gzip_comp_level 6;
81gzip_buffers 16 8k;
82gzip_http_version 1.1;
83gzip_min_length 256;
84# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
85gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-fon$
86
87#mail {
88# # See sample authentication script at:
89# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
90#
91# # auth_http localhost/auth.php;
92# # pop3_capabilities "TOP" "USER";
93# # imap_capabilities "IMAP4rev1" "UIDPLUS";
94#
95# server {
96# listen localhost:110;
97# protocol pop3;
98# proxy on;
99# }
100#
101# server {
102# listen localhost:143;
103# protocol imap;
104# proxy on;
105# }
106#}
107
108"""
109Django settings for project project.
110
111Generated by 'django-admin startproject' using Django 1.10.2.
112
113For more information on this file, see
114https://docs.djangoproject.com/en/1.10/topics/settings/
115
116For the full list of settings and their values, see
117https://docs.djangoproject.com/en/1.10/ref/settings/
118"""
119
120import os
121from local_settings import *
122
123# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
124BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
125
126
127# Quick-start development settings - unsuitable for production
128# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
129
130# SECURITY WARNING: keep the secret key used in production secret!
131SECRET_KEY = 'lgdgl;dgl;keks;lfjjtd;fldgl;;gldgfsfsgldgdlgdlp[gdgdgdgd'
132
133
134# Application definition
135
136INSTALLED_APPS = [
137 'django.contrib.admin',
138 'django.contrib.auth',
139 'django.contrib.contenttypes',
140 'django.contrib.sessions',
141 'django.contrib.messages',
142 'django.contrib.staticfiles',
143 'solo',
144 'nested_admin',
145 'project',
146 'main',
147 'ckeditor',
148 'ckeditor_uploader',
149]
150
151MIDDLEWARE = [
152 'django.middleware.security.SecurityMiddleware',
153 'django.contrib.sessions.middleware.SessionMiddleware',
154 'django.middleware.common.CommonMiddleware',
155 # 'django.middleware.csrf.CsrfViewMiddleware',
156 'django.contrib.auth.middleware.AuthenticationMiddleware',
157 'django.contrib.messages.middleware.MessageMiddleware',
158 'django.middleware.clickjacking.XFrameOptionsMiddleware',
159]
160
161ROOT_URLCONF = 'project.urls'
162
163TEMPLATES = [
164 {
165 'BACKEND': 'django.template.backends.django.DjangoTemplates',
166 'DIRS': [],
167 'APP_DIRS': True,
168 'OPTIONS': {
169 'context_processors': [
170 'django.template.context_processors.debug',
171 'django.template.context_processors.request',
172 'django.contrib.auth.context_processors.auth',
173 'django.contrib.messages.context_processors.messages',
174 ],
175 },
176 },
177]
178
179WSGI_APPLICATION = 'project.wsgi.application'
180
181
182# Password validation
183# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
184
185AUTH_PASSWORD_VALIDATORS = [
186 {
187 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
188 },
189 {
190 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
191 },
192 {
193 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
194 },
195 {
196 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
197 },
198]
199
200
201# Internationalization
202# https://docs.djangoproject.com/en/1.10/topics/i18n/
203
204LANGUAGE_CODE = 'ru-ru'
205
206TIME_ZONE = 'Europe/Kiev'
207
208USE_I18N = True
209
210USE_L10N = True
211
212USE_TZ = True
213
214
215# Static files (CSS, JavaScript, Images)
216# https://docs.djangoproject.com/en/1.10/howto/static-files/
217
218STATIC_URL = '/static/'
219
220STATIC_ROOT = os.path.join(BASE_DIR, 'project', 'static')
221
222
223MEDIA_URL = '/media/'
224
225MEDIA_ROOT = os.path.join(BASE_DIR, 'project', 'media')
226
227
228CKEDITOR_UPLOAD_PATH = "uploads/"
229
230CKEDITOR_JQUERY_URL = '/static/design/js/jquery.2.1.1.min.js'
231
232CKEDITOR_CONFIGS = {
233 'default': {
234 'toolbar': 'full',
235 'forcePasteAsPlainText': True,
236 }
237}
238
239
240EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
241DEFAULT_FROM_EMAIL = 'site@gmail.com'
242EMAIL_USE_TLS = True
243EMAIL_HOST = 'smtp.gmail.com'
244EMAIL_HOST_USER = 'site@gmail.com'
245EMAIL_HOST_PASSWORD = '123456'
246EMAIL_PORT = 587
247
248DEBUG = False
249
250ALLOWED_HOSTS = ['site.com.ua', 'www.site.com.ua', 'x.xx.xxx.xxx']
251
252DATABASES = {
253 'default': {
254 'ENGINE': 'django.db.backends.mysql',
255 'NAME': 'site',
256 'USER': 'site',
257 'PASSWORD': '123456',
258 'HOST': 'localhost',
259 'PORT': '',
260 }
261}
262
263def order(request):
264 if request.method == 'POST':
265 form = OrderForm(request.POST)
266 if form.is_valid():
267 form = form.save(commit=False)
268 email = form.order_email
269 if email:
270 name = unicode(form.order_name)
271 email = unicode(email)
272 text = name + u', ÑпаÑибо, мы Вашу заÑвку получили! Ðаш менеджер Ñ Ð’Ð°Ð¼Ð¸ ÑвÑжетÑÑ Ð² ближаййшее времÑ.'
273 msg = EmailMessage(u'Ваша заÑвка принÑта', text, u'site@gmail.com', [email])
274 msg.content_subtype = "html"
275 msg.send()
276 form.save()
277 return HttpResponse('ok')
278
279from django.forms import *
280from .models import Order
281
282class OrderForm(ModelForm):
283 class Meta:
284 model = Order
285 fields = '__all__'