[Django3.0]MySQLへのデータ登録

受け取る側のviews.pyでModesに入れれば良い

/sales/views.py

from django.shortcuts import render
from django.http import HttpResponse
from .models import Master

def master_complete(request):
	if(request.method == 'POST'):
		name = request.POST['name']
		office = request.POST['office']
		zipcode = request.POST['zipcode']
		prefecture = request.POST['prefecture']
		address = request.POST['address']
		tel = request.POST['tel']
		fax = request.POST['fax']
		mail = request.POST['mail']
		name_top = request.POST['name_top']
		position_top = request.POST['position_top']
		master = Master(name=name, office=office, zipcode=zipcode, prefecture=prefecture, address=address,
			tel=tel,fax=fax, mail=mail, name_top=name_top, position_top=position_top)
		master.save()
	return render(request, 'sales/master_complete.html')

mysql> select * from sales_master;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect…
Connection id: 44
Current database: hanbai

+—-+————————————–+——–+———-+————+—————————-+————–+————–+——————–+————–+—————–+—————————-+—————————-+
| id | name | office | zipcode | prefecture | address | tel | fax | mail | name_top | position_top | created_at | updated_at |
+—-+————————————–+——–+———-+————+—————————-+————–+————–+——————–+————–+—————–+—————————-+—————————-+
| 1 | 東京テクノロジー株式会社 | 本社 | 100-6321 | 東京都 | 千代田区丸の内2-4-1 | 03-1234-5678 | 03-1234-5679 | info@tokyotech.com | 山田太郎 | 代表取締役 | 2020-08-22 12:30:30.000000 | 2020-08-22 12:30:30.000000 |
| 2 | テスト | 本社 | 100-0001 | 東京都 | 千代田区千代田1-1-1 | 03-1234-5678 | 03-1234-5679 | test@gmail.com | 山田太郎 | | 2020-08-26 22:03:28.299894 | 2020-08-26 22:03:28.299937 |
+—-+————————————–+——–+———-+————+—————————-+————–+————–+——————–+————–+—————–+—————————-+—————————-+
2 rows in set (0.00 sec)