質問するログイン新規登録

質問編集履歴

2

dbshell上のコマンド追記

2017/08/29 23:41

投稿

kazzzstudio
kazzzstudio

スコア94

title CHANGED
File without changes
body CHANGED
@@ -69,6 +69,9 @@
69
69
  (0 rows)
70
70
 
71
71
  remoshin_maindb=# select * from remosys_remoshin_user_tbl;
72
+ remoshin_maindb=# select * from authtoken_token_user_id_key";
73
+ remoshin_maindb"# select max(id) from authtoken_token_user_id_key;
74
+ remoshin_maindb"#
72
75
  remoshin_maindb=# \q
73
76
  (remoshin) ubuntu@ip-172-31-33-33:~/remoshin/remoshin$ python3 manage.py createsuperuser
74
77
  (省略)

1

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

2017/08/29 23:41

投稿

kazzzstudio
kazzzstudio

スコア94

title CHANGED
File without changes
body CHANGED
@@ -17,4 +17,222 @@
17
17
  見当もつきません(Userテーブルも空です)。
18
18
 
19
19
  どなたかご見識の方がいらっしゃいましたら、ぜひご教示いただけると幸いです。
20
- よろしくお願いいたします。
20
+ よろしくお願いいたします。
21
+
22
+
23
+ 追記(1)
24
+
25
+ dbshell実行時の出力は下記のようになります。
26
+
27
+ ```ここに言語を入力
28
+ (remoshin) ubuntu@ip-172-31-33-33:~/remoshin/remoshin$ python3 manage.py makemigrations
29
+ (remoshin) ubuntu@ip-172-31-33-33:~/remoshin/remoshin$ python3 manage.py migrate
30
+ (remoshin) ubuntu@ip-172-31-33-33:~/remoshin/remoshin$ python3 manage.py dbshell
31
+ psql (9.5.8)
32
+ SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
33
+ Type "help" for help.
34
+
35
+ remoshin_maindb=# \dt
36
+ List of relations
37
+ Schema | Name | Type | Owner
38
+ --------+-----------------------------------------------+-------+---------
39
+ public | auth_group | table | remosys
40
+ public | auth_group_permissions | table | remosys
41
+ public | auth_permission | table | remosys
42
+ public | authtoken_token | table | remosys
43
+ public | django_admin_log | table | remosys
44
+ public | django_content_type | table | remosys
45
+ public | django_migrations | table | remosys
46
+ public | django_session | table | remosys
47
+ public | remosys_chat_detail_tbl | table | remosys
48
+ public | remosys_chat_tbl | table | remosys
49
+ public | remosys_clinic_ipaddress_tbl | table | remosys
50
+ public | remosys_clinic_open_tbl | table | remosys
51
+ public | remosys_clinic_tbl | table | remosys
52
+ public | remosys_consultation_menu_tbl | table | remosys
53
+ public | remosys_consultation_tbl | table | remosys
54
+ public | remosys_department_tbl | table | remosys
55
+ public | remosys_error_tbl | table | remosys
56
+ public | remosys_menu_tbl | table | remosys
57
+ public | remosys_refund_request_tbl | table | remosys
58
+ public | remosys_remoshin_doctor_tbl | table | remosys
59
+ public | remosys_remoshin_manager_tbl | table | remosys
60
+ public | remosys_remoshin_manager_tbl_groups | table | remosys
61
+ public | remosys_remoshin_manager_tbl_user_permissions | table | remosys
62
+ public | remosys_remoshin_user_tbl | table | remosys
63
+ public | remosys_statement_tbl | table | remosys
64
+ (25 rows)
65
+
66
+ remoshin_maindb=# select * from authtoken_token;
67
+ key | created | user_id
68
+ -----+---------+---------
69
+ (0 rows)
70
+
71
+ remoshin_maindb=# select * from remosys_remoshin_user_tbl;
72
+ remoshin_maindb=# \q
73
+ (remoshin) ubuntu@ip-172-31-33-33:~/remoshin/remoshin$ python3 manage.py createsuperuser
74
+ (省略)
75
+ File "/home/ubuntu/remoshin/lib/python3.5/site-packages/django/db/backends/utils.py", line 65, in execute
76
+ return self.cursor.execute(sql, params)
77
+ psycopg2.IntegrityError: duplicate key value violates unique constraint "authtoken_token_user_id_key"
78
+ DETAIL: Key (user_id)=(abcdef@gmail.com) already exists.
79
+ ```
80
+
81
+ 追記2)
82
+ 使用ソフトウェアのバージョン
83
+
84
+ python 3.5.2
85
+ OS Ubuntu 16.4 LTS (AWS)
86
+ Django-1.11.4
87
+
88
+ settings.py
89
+ ```
90
+ import os
91
+ from django.core.urlresolvers import reverse_lazy
92
+
93
+ # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
94
+ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
95
+
96
+
97
+ DJANGO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
98
+ PROJECT_ROOT = os.path.dirname(DJANGO_ROOT)
99
+
100
+ LOGIN_REDIRECT_URL = reverse_lazy('main')
101
+ LOGIN_URL = reverse_lazy('login')
102
+ LOGOUT_URL = reverse_lazy('logout')
103
+ LOGIN_ERROR_URL = reverse_lazy('login')
104
+
105
+ SECRET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
106
+
107
+ DEBUG = True
108
+
109
+ ALLOWED_HOSTS = ['app.myserver.com']
110
+
111
+ AUTH_USER_MODEL = 'user.RemoshinUser'
112
+
113
+ AUTHENTICATION_BACKENDS = {'user.backends.RemoshinUserAuth',}
114
+
115
+ # Application definition
116
+
117
+ INSTALLED_APPS = [
118
+ 'django.contrib.admin',
119
+ 'django.contrib.auth',
120
+ 'django.contrib.contenttypes',
121
+ 'django.contrib.sessions',
122
+ 'django.contrib.messages',
123
+ 'django.contrib.staticfiles',
124
+ 'rest_framework',
125
+ 'rest_framework.authtoken',
126
+ 'corsheaders',
127
+ 'remoshin',
128
+ 'user',
129
+ ]
130
+
131
+ MIDDLEWARE = [
132
+ 'django.middleware.security.SecurityMiddleware',
133
+ 'django.contrib.sessions.middleware.SessionMiddleware',
134
+ 'django.middleware.common.CommonMiddleware',
135
+ 'django.middleware.csrf.CsrfViewMiddleware',
136
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
137
+ 'django.contrib.messages.middleware.MessageMiddleware',
138
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
139
+ ]
140
+
141
+ ROOT_URLCONF = 'remoshin.urls'
142
+
143
+ TEMPLATES = [
144
+ {
145
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
146
+ 'DIRS': [os.path.join(BASE_DIR, 'templates')],
147
+ 'APP_DIRS': True,
148
+ 'OPTIONS': {
149
+ 'context_processors': [
150
+ 'django.template.context_processors.debug',
151
+ 'django.template.context_processors.request',
152
+ 'django.contrib.auth.context_processors.auth',
153
+ 'django.contrib.messages.context_processors.messages',
154
+ ],
155
+ },
156
+ },
157
+ ]
158
+ TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates/registration')]
159
+
160
+
161
+ WSGI_APPLICATION = 'remoshin_user.wsgi.application'
162
+
163
+
164
+ # Database
165
+ # https://docs.djangoproject.com/en/1.11/ref/settings/#databases
166
+
167
+ DATABASES = {
168
+ 'default': {
169
+ 'ENGINE': 'django.db.backends.postgresql_psycopg2',
170
+ 'NAME': 'db_name',
171
+ 'USER': 'db_user',
172
+ 'PASSWORD' : 'db_password',
173
+ 'HOST' : '127.0.0.1',
174
+ 'PORT' : 5432,
175
+ }
176
+ }
177
+
178
+
179
+ # Password validation
180
+ # https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
181
+
182
+ AUTH_PASSWORD_VALIDATORS = [
183
+ {
184
+ 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
185
+ },
186
+ {
187
+ 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
188
+ },
189
+ {
190
+ 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
191
+ },
192
+ {
193
+ 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
194
+ },
195
+ ]
196
+
197
+
198
+ # REST API用の設定
199
+ JWT_AUTH = {
200
+ 'JWT_VERIFY_EXPIRATION': False,
201
+ 'JWT_AUTH_HEADER_PREFIX': 'JWT',
202
+ }
203
+
204
+
205
+ REST_FRAMEWORK = {
206
+ 'DEFAULT_PERMISSION_CLASSES': (
207
+ 'rest_framework.permissions.IsAuthenticated',
208
+ ),
209
+ 'DEFAULT_AUTHENTICATION_CLASSES': (
210
+ 'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
211
+ ),
212
+ 'NON_FIELD_ERRORS_KEY': 'detail',
213
+ 'TEST_REQUEST_DEFAULT_FORMAT': 'json'
214
+ }
215
+
216
+
217
+
218
+
219
+
220
+ # Internationalization
221
+ # https://docs.djangoproject.com/en/1.11/topics/i18n/
222
+
223
+ LANGUAGE_CODE = 'ja'
224
+
225
+ TIME_ZONE = 'Asia/Tokyo'
226
+
227
+ USE_I18N = True
228
+
229
+ USE_L10N = True
230
+
231
+ USE_TZ = True
232
+
233
+
234
+ # Static files (CSS, JavaScript, Images)
235
+ # https://docs.djangoproject.com/en/1.11/howto/static-files/
236
+
237
+ STATIC_URL = '/static/'
238
+ ```