質問編集履歴
1
書式の改善
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
テーブルに情報が反映されない。
|
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Django allauthを使った認証機能実装をしようとしています。
|
2
2
|
|
3
|
-
formに入力して送信を押しても
|
3
|
+
formに入力して送信を押してもテーブルに反映されません。
|
4
4
|
|
5
5
|
|
6
6
|
|
@@ -98,96 +98,6 @@
|
|
98
98
|
|
99
99
|
attrs={'placeholder':'担当者名 性', 'class': ''}))
|
100
100
|
|
101
|
-
administrater_firstname = forms.CharField(
|
102
|
-
|
103
|
-
label=('担当者名 名'),
|
104
|
-
|
105
|
-
help_text='※必須',
|
106
|
-
|
107
|
-
widget=forms.TextInput(
|
108
|
-
|
109
|
-
attrs={'placeholder':'担当者名 名', 'class': ''}))
|
110
|
-
|
111
|
-
administrater_lastname_kana = forms.CharField(
|
112
|
-
|
113
|
-
label=('担当者名 セイ'),
|
114
|
-
|
115
|
-
help_text='※必須',
|
116
|
-
|
117
|
-
widget=forms.TextInput(
|
118
|
-
|
119
|
-
attrs={'placeholder':'担当者名 セイ', 'class': ''}))
|
120
|
-
|
121
|
-
administrater_firstname_kana = forms.CharField(
|
122
|
-
|
123
|
-
label=('担当者名 メイ'),
|
124
|
-
|
125
|
-
help_text='※必須',
|
126
|
-
|
127
|
-
widget=forms.TextInput(
|
128
|
-
|
129
|
-
attrs={'placeholder':'担当者名 メイ', 'class': ''}))
|
130
|
-
|
131
|
-
department = forms.CharField(
|
132
|
-
|
133
|
-
label=('部署'),
|
134
|
-
|
135
|
-
help_text='※任意',
|
136
|
-
|
137
|
-
widget=forms.TextInput(
|
138
|
-
|
139
|
-
attrs={'placeholder':'役職', 'class': ''}))
|
140
|
-
|
141
|
-
clerk = forms.CharField(
|
142
|
-
|
143
|
-
label=('役職'),
|
144
|
-
|
145
|
-
help_text='※必須',
|
146
|
-
|
147
|
-
widget=forms.TextInput(
|
148
|
-
|
149
|
-
attrs={'placeholder':'役職', 'class': ''}))
|
150
|
-
|
151
|
-
zipcode = forms.CharField(
|
152
|
-
|
153
|
-
label=('郵便番号'),
|
154
|
-
|
155
|
-
help_text='※必須',
|
156
|
-
|
157
|
-
widget=forms.TextInput(
|
158
|
-
|
159
|
-
attrs={'placeholder':'郵便番号', 'class': ''}))
|
160
|
-
|
161
|
-
prefecture = forms.CharField(
|
162
|
-
|
163
|
-
label=('都道府県'),
|
164
|
-
|
165
|
-
help_text='※必須',
|
166
|
-
|
167
|
-
widget=forms.TextInput(
|
168
|
-
|
169
|
-
attrs={'placeholder':'都道府県', 'class': ''}))
|
170
|
-
|
171
|
-
address_number = forms.CharField(
|
172
|
-
|
173
|
-
label=('市区町村番地'),
|
174
|
-
|
175
|
-
help_text='※必須',
|
176
|
-
|
177
|
-
widget=forms.TextInput(
|
178
|
-
|
179
|
-
attrs={'placeholder':'市区町村番地', 'class': ''}))
|
180
|
-
|
181
|
-
address_building = forms.CharField(
|
182
|
-
|
183
|
-
label=('建物名'),
|
184
|
-
|
185
|
-
help_text='※任意',
|
186
|
-
|
187
|
-
widget=forms.TextInput(
|
188
|
-
|
189
|
-
attrs={'placeholder':'建物名', 'class': ''}))
|
190
|
-
|
191
101
|
|
192
102
|
|
193
103
|
class Meta:
|
@@ -206,7 +116,7 @@
|
|
206
116
|
|
207
117
|
user.representative = self.cleaned_data['representative']
|
208
118
|
|
209
|
-
|
119
|
+
user.administrater_lastname = self.cleaned_data['administrater_lastname']
|
210
120
|
|
211
121
|
user.save()
|
212
122
|
|
@@ -314,135 +224,7 @@
|
|
314
224
|
|
315
225
|
{% csrf_token%}
|
316
226
|
|
317
|
-
<div class="field registration_field">
|
318
|
-
|
319
|
-
{{form.username.label_tag}}
|
320
|
-
|
321
|
-
{{form.username}}
|
322
|
-
|
323
|
-
{% if field.help_text %}
|
324
|
-
|
325
|
-
<span class="helptext">{{ field.help_text }}</span>
|
326
|
-
|
327
|
-
{% endif %}
|
328
|
-
|
329
|
-
{{ field }}
|
330
|
-
|
331
|
-
{{ field.errors }}
|
332
|
-
|
333
|
-
</div>
|
334
|
-
|
335
|
-
<div class="field registration_field">
|
336
|
-
|
337
|
-
{{form.company_name_kana.label_tag}}
|
338
|
-
|
339
|
-
{{form.company_name_kana}}
|
340
|
-
|
341
|
-
{% if field.help_text %}
|
342
|
-
|
343
|
-
<span class="helptext">{{ field.help_text }}</span>
|
344
|
-
|
345
|
-
{% endif %}
|
346
|
-
|
347
|
-
{{ field }}
|
348
|
-
|
349
|
-
{{ field.errors }}
|
350
|
-
|
351
|
-
</div>
|
352
|
-
|
353
|
-
<div class="field registration_field">
|
354
|
-
|
355
|
-
{{form.電話番号.label_tag}}
|
356
|
-
|
357
|
-
|
227
|
+
{{form.as_p}}
|
358
|
-
|
359
|
-
{% if field.help_text %}
|
360
|
-
|
361
|
-
<span class="helptext">{{ field.help_text }}</span>
|
362
|
-
|
363
|
-
{% endif %}
|
364
|
-
|
365
|
-
{{ field }}
|
366
|
-
|
367
|
-
{{ field.errors }}
|
368
|
-
|
369
|
-
</div>
|
370
|
-
|
371
|
-
<div class="field registration_field">
|
372
|
-
|
373
|
-
{{form.email.label_tag}}
|
374
|
-
|
375
|
-
{{form.email}}
|
376
|
-
|
377
|
-
{% if field.help_text %}
|
378
|
-
|
379
|
-
<span class="helptext">{{ field.help_text }}</span>
|
380
|
-
|
381
|
-
{% endif %}
|
382
|
-
|
383
|
-
{{ field }}
|
384
|
-
|
385
|
-
{{ field.errors }}
|
386
|
-
|
387
|
-
</div>
|
388
|
-
|
389
|
-
<div class="field registration_field">
|
390
|
-
|
391
|
-
{{form.representative.label_tag}}
|
392
|
-
|
393
|
-
{{form.representative}}
|
394
|
-
|
395
|
-
{% if field.help_text %}
|
396
|
-
|
397
|
-
<span class="helptext">{{ field.help_text }}</span>
|
398
|
-
|
399
|
-
{% endif %}
|
400
|
-
|
401
|
-
{{ field }}
|
402
|
-
|
403
|
-
{{ field.errors }}
|
404
|
-
|
405
|
-
</div>
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
<h2>担当者情報</h2>
|
410
|
-
|
411
|
-
<div class="field registration_field">
|
412
|
-
|
413
|
-
{{form.administrater_lastname.label_tag}}
|
414
|
-
|
415
|
-
{{form.administrater_lastname}}
|
416
|
-
|
417
|
-
{% if field.help_text %}
|
418
|
-
|
419
|
-
<span class="helptext">{{ field.help_text }}</span>
|
420
|
-
|
421
|
-
{% endif %}
|
422
|
-
|
423
|
-
{{ field }}
|
424
|
-
|
425
|
-
{{ field.errors }}
|
426
|
-
|
427
|
-
</div>
|
428
|
-
|
429
|
-
<div class="field registration_field">
|
430
|
-
|
431
|
-
{{form.administrater_firstname.label_tag}}
|
432
|
-
|
433
|
-
{{form.administrater_firstname}}
|
434
|
-
|
435
|
-
{% if field.help_text %}
|
436
|
-
|
437
|
-
<span class="helptext">{{ field.help_text }}</span>
|
438
|
-
|
439
|
-
{% endif %}
|
440
|
-
|
441
|
-
{{ field }}
|
442
|
-
|
443
|
-
{{ field.errors }}
|
444
|
-
|
445
|
-
|
446
228
|
|
447
229
|
|
448
230
|
|
@@ -472,12 +254,56 @@
|
|
472
254
|
|
473
255
|
```
|
474
256
|
|
257
|
+
adapter.py
|
258
|
+
|
259
|
+
```
|
260
|
+
|
261
|
+
from allauth.account.adapter import DefaultAccountAdapter
|
262
|
+
|
263
|
+
|
264
|
+
|
475
|
-
|
265
|
+
class AccountAdapter(DefaultAccountAdapter):
|
476
|
-
|
266
|
+
|
267
|
+
|
268
|
+
|
477
|
-
|
269
|
+
def save_user(self, request, user, form, commit=True):
|
478
|
-
|
479
|
-
|
480
|
-
|
270
|
+
|
481
|
-
|
271
|
+
"""
|
272
|
+
|
273
|
+
This is called when saving user via allauth registration.
|
274
|
+
|
275
|
+
We override this to set additional data on user object.
|
276
|
+
|
277
|
+
"""
|
278
|
+
|
279
|
+
# Do not persist the user yet so we pass commit=False
|
280
|
+
|
281
|
+
# (last argument)
|
282
|
+
|
283
|
+
user = super(AccountAdapter, self).save_user(request, user, form, commit=False)
|
284
|
+
|
285
|
+
user.phone_number = form.cleaned_data.get('電話番号')
|
286
|
+
|
287
|
+
user.company_name = form.cleaned_data.get('username')
|
288
|
+
|
289
|
+
user.company_name_kana =form.cleaned_data.get('company_name_kana')
|
290
|
+
|
291
|
+
user.representative = form.cleaned_data.get('representative')
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
user.administrater_lastname = form.cleaned_data.get('administrater_lastname')
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
user.save()
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
```
|
304
|
+
|
305
|
+
フィールドに入力し、登録ボタンを押すときちんと遷移し、customuserテーブルにはデータが入りますが、administraterテーブルには入りません。
|
306
|
+
|
307
|
+
|
482
308
|
|
483
309
|
なぜでしょうか?
|