質問編集履歴

2

dbshell上のコマンド追記

2017/08/29 23:41

投稿

kazzzstudio
kazzzstudio

スコア94

test CHANGED
File without changes
test CHANGED
@@ -140,6 +140,12 @@
140
140
 
141
141
  remoshin_maindb=# select * from remosys_remoshin_user_tbl;
142
142
 
143
+ remoshin_maindb=# select * from authtoken_token_user_id_key";
144
+
145
+ remoshin_maindb"# select max(id) from authtoken_token_user_id_key;
146
+
147
+ remoshin_maindb"#
148
+
143
149
  remoshin_maindb=# \q
144
150
 
145
151
  (remoshin) ubuntu@ip-172-31-33-33:~/remoshin/remoshin$ python3 manage.py createsuperuser

1

コマンド実行時の出力および設定ファイル

2017/08/29 23:41

投稿

kazzzstudio
kazzzstudio

スコア94

test CHANGED
File without changes
test CHANGED
@@ -37,3 +37,439 @@
37
37
  どなたかご見識の方がいらっしゃいましたら、ぜひご教示いただけると幸いです。
38
38
 
39
39
  よろしくお願いいたします。
40
+
41
+
42
+
43
+
44
+
45
+ 追記(1)
46
+
47
+
48
+
49
+ dbshell実行時の出力は下記のようになります。
50
+
51
+
52
+
53
+ ```ここに言語を入力
54
+
55
+ (remoshin) ubuntu@ip-172-31-33-33:~/remoshin/remoshin$ python3 manage.py makemigrations
56
+
57
+ (remoshin) ubuntu@ip-172-31-33-33:~/remoshin/remoshin$ python3 manage.py migrate
58
+
59
+ (remoshin) ubuntu@ip-172-31-33-33:~/remoshin/remoshin$ python3 manage.py dbshell
60
+
61
+ psql (9.5.8)
62
+
63
+ SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
64
+
65
+ Type "help" for help.
66
+
67
+
68
+
69
+ remoshin_maindb=# \dt
70
+
71
+ List of relations
72
+
73
+ Schema | Name | Type | Owner
74
+
75
+ --------+-----------------------------------------------+-------+---------
76
+
77
+ public | auth_group | table | remosys
78
+
79
+ public | auth_group_permissions | table | remosys
80
+
81
+ public | auth_permission | table | remosys
82
+
83
+ public | authtoken_token | table | remosys
84
+
85
+ public | django_admin_log | table | remosys
86
+
87
+ public | django_content_type | table | remosys
88
+
89
+ public | django_migrations | table | remosys
90
+
91
+ public | django_session | table | remosys
92
+
93
+ public | remosys_chat_detail_tbl | table | remosys
94
+
95
+ public | remosys_chat_tbl | table | remosys
96
+
97
+ public | remosys_clinic_ipaddress_tbl | table | remosys
98
+
99
+ public | remosys_clinic_open_tbl | table | remosys
100
+
101
+ public | remosys_clinic_tbl | table | remosys
102
+
103
+ public | remosys_consultation_menu_tbl | table | remosys
104
+
105
+ public | remosys_consultation_tbl | table | remosys
106
+
107
+ public | remosys_department_tbl | table | remosys
108
+
109
+ public | remosys_error_tbl | table | remosys
110
+
111
+ public | remosys_menu_tbl | table | remosys
112
+
113
+ public | remosys_refund_request_tbl | table | remosys
114
+
115
+ public | remosys_remoshin_doctor_tbl | table | remosys
116
+
117
+ public | remosys_remoshin_manager_tbl | table | remosys
118
+
119
+ public | remosys_remoshin_manager_tbl_groups | table | remosys
120
+
121
+ public | remosys_remoshin_manager_tbl_user_permissions | table | remosys
122
+
123
+ public | remosys_remoshin_user_tbl | table | remosys
124
+
125
+ public | remosys_statement_tbl | table | remosys
126
+
127
+ (25 rows)
128
+
129
+
130
+
131
+ remoshin_maindb=# select * from authtoken_token;
132
+
133
+ key | created | user_id
134
+
135
+ -----+---------+---------
136
+
137
+ (0 rows)
138
+
139
+
140
+
141
+ remoshin_maindb=# select * from remosys_remoshin_user_tbl;
142
+
143
+ remoshin_maindb=# \q
144
+
145
+ (remoshin) ubuntu@ip-172-31-33-33:~/remoshin/remoshin$ python3 manage.py createsuperuser
146
+
147
+ (省略)
148
+
149
+ File "/home/ubuntu/remoshin/lib/python3.5/site-packages/django/db/backends/utils.py", line 65, in execute
150
+
151
+ return self.cursor.execute(sql, params)
152
+
153
+ psycopg2.IntegrityError: duplicate key value violates unique constraint "authtoken_token_user_id_key"
154
+
155
+ DETAIL: Key (user_id)=(abcdef@gmail.com) already exists.
156
+
157
+ ```
158
+
159
+
160
+
161
+ 追記2)
162
+
163
+ 使用ソフトウェアのバージョン
164
+
165
+
166
+
167
+ python 3.5.2
168
+
169
+ OS Ubuntu 16.4 LTS (AWS)
170
+
171
+ Django-1.11.4
172
+
173
+
174
+
175
+ settings.py
176
+
177
+ ```
178
+
179
+ import os
180
+
181
+ from django.core.urlresolvers import reverse_lazy
182
+
183
+
184
+
185
+ # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
186
+
187
+ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
188
+
189
+
190
+
191
+
192
+
193
+ DJANGO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
194
+
195
+ PROJECT_ROOT = os.path.dirname(DJANGO_ROOT)
196
+
197
+
198
+
199
+ LOGIN_REDIRECT_URL = reverse_lazy('main')
200
+
201
+ LOGIN_URL = reverse_lazy('login')
202
+
203
+ LOGOUT_URL = reverse_lazy('logout')
204
+
205
+ LOGIN_ERROR_URL = reverse_lazy('login')
206
+
207
+
208
+
209
+ SECRET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
210
+
211
+
212
+
213
+ DEBUG = True
214
+
215
+
216
+
217
+ ALLOWED_HOSTS = ['app.myserver.com']
218
+
219
+
220
+
221
+ AUTH_USER_MODEL = 'user.RemoshinUser'
222
+
223
+
224
+
225
+ AUTHENTICATION_BACKENDS = {'user.backends.RemoshinUserAuth',}
226
+
227
+
228
+
229
+ # Application definition
230
+
231
+
232
+
233
+ INSTALLED_APPS = [
234
+
235
+ 'django.contrib.admin',
236
+
237
+ 'django.contrib.auth',
238
+
239
+ 'django.contrib.contenttypes',
240
+
241
+ 'django.contrib.sessions',
242
+
243
+ 'django.contrib.messages',
244
+
245
+ 'django.contrib.staticfiles',
246
+
247
+ 'rest_framework',
248
+
249
+ 'rest_framework.authtoken',
250
+
251
+ 'corsheaders',
252
+
253
+ 'remoshin',
254
+
255
+ 'user',
256
+
257
+ ]
258
+
259
+
260
+
261
+ MIDDLEWARE = [
262
+
263
+ 'django.middleware.security.SecurityMiddleware',
264
+
265
+ 'django.contrib.sessions.middleware.SessionMiddleware',
266
+
267
+ 'django.middleware.common.CommonMiddleware',
268
+
269
+ 'django.middleware.csrf.CsrfViewMiddleware',
270
+
271
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
272
+
273
+ 'django.contrib.messages.middleware.MessageMiddleware',
274
+
275
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
276
+
277
+ ]
278
+
279
+
280
+
281
+ ROOT_URLCONF = 'remoshin.urls'
282
+
283
+
284
+
285
+ TEMPLATES = [
286
+
287
+ {
288
+
289
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
290
+
291
+ 'DIRS': [os.path.join(BASE_DIR, 'templates')],
292
+
293
+ 'APP_DIRS': True,
294
+
295
+ 'OPTIONS': {
296
+
297
+ 'context_processors': [
298
+
299
+ 'django.template.context_processors.debug',
300
+
301
+ 'django.template.context_processors.request',
302
+
303
+ 'django.contrib.auth.context_processors.auth',
304
+
305
+ 'django.contrib.messages.context_processors.messages',
306
+
307
+ ],
308
+
309
+ },
310
+
311
+ },
312
+
313
+ ]
314
+
315
+ TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates/registration')]
316
+
317
+
318
+
319
+
320
+
321
+ WSGI_APPLICATION = 'remoshin_user.wsgi.application'
322
+
323
+
324
+
325
+
326
+
327
+ # Database
328
+
329
+ # https://docs.djangoproject.com/en/1.11/ref/settings/#databases
330
+
331
+
332
+
333
+ DATABASES = {
334
+
335
+ 'default': {
336
+
337
+ 'ENGINE': 'django.db.backends.postgresql_psycopg2',
338
+
339
+ 'NAME': 'db_name',
340
+
341
+ 'USER': 'db_user',
342
+
343
+ 'PASSWORD' : 'db_password',
344
+
345
+ 'HOST' : '127.0.0.1',
346
+
347
+ 'PORT' : 5432,
348
+
349
+ }
350
+
351
+ }
352
+
353
+
354
+
355
+
356
+
357
+ # Password validation
358
+
359
+ # https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
360
+
361
+
362
+
363
+ AUTH_PASSWORD_VALIDATORS = [
364
+
365
+ {
366
+
367
+ 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
368
+
369
+ },
370
+
371
+ {
372
+
373
+ 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
374
+
375
+ },
376
+
377
+ {
378
+
379
+ 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
380
+
381
+ },
382
+
383
+ {
384
+
385
+ 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
386
+
387
+ },
388
+
389
+ ]
390
+
391
+
392
+
393
+
394
+
395
+ # REST API用の設定
396
+
397
+ JWT_AUTH = {
398
+
399
+ 'JWT_VERIFY_EXPIRATION': False,
400
+
401
+ 'JWT_AUTH_HEADER_PREFIX': 'JWT',
402
+
403
+ }
404
+
405
+
406
+
407
+
408
+
409
+ REST_FRAMEWORK = {
410
+
411
+ 'DEFAULT_PERMISSION_CLASSES': (
412
+
413
+ 'rest_framework.permissions.IsAuthenticated',
414
+
415
+ ),
416
+
417
+ 'DEFAULT_AUTHENTICATION_CLASSES': (
418
+
419
+ 'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
420
+
421
+ ),
422
+
423
+ 'NON_FIELD_ERRORS_KEY': 'detail',
424
+
425
+ 'TEST_REQUEST_DEFAULT_FORMAT': 'json'
426
+
427
+ }
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+
436
+
437
+
438
+
439
+ # Internationalization
440
+
441
+ # https://docs.djangoproject.com/en/1.11/topics/i18n/
442
+
443
+
444
+
445
+ LANGUAGE_CODE = 'ja'
446
+
447
+
448
+
449
+ TIME_ZONE = 'Asia/Tokyo'
450
+
451
+
452
+
453
+ USE_I18N = True
454
+
455
+
456
+
457
+ USE_L10N = True
458
+
459
+
460
+
461
+ USE_TZ = True
462
+
463
+
464
+
465
+
466
+
467
+ # Static files (CSS, JavaScript, Images)
468
+
469
+ # https://docs.djangoproject.com/en/1.11/howto/static-files/
470
+
471
+
472
+
473
+ STATIC_URL = '/static/'
474
+
475
+ ```