Django 重写用户模型

13 篇文章 0 订阅

Django 重写用户模型:
Django内建的 User 模型可能不适合某些类型的项目。例如,在某些网站上使用邮件地址而不是用户名作为身份的标识可能更合理,或者需要增加 用户的所在部门列。
这是我们就需要扩展Django内建的 User 模型

1.编写代码:
settings.py
	# AUTH_USER_MODEL = 'src.apps.workorder.models.MyUser'
	AUTH_USER_MODEL = 'workorder.MyUser'



path/to/app/models.py
	from django.contrib.auth.models import AbstractUser
	class MyUser(AbstractUser):
		dept_name = models.CharField(max_length=256)
		class Meta:
			db_table = 'myuser'
			app_label = 'workorder'
		
		
		
2.清除 Django 框架的原生表: 
	auth_group                 
	auth_group_permissions     
	auth_permission    
			
	auth_user                  
	auth_user_groups           
	auth_user_user_permissions 	

	django_admin_log         
	django_content_type      
	django_migrations        
	django_session    


3.执行 makemigrations 生成迁移脚本:
	(xdbamq_env) root@robert-Ubuntu:/media/sf_WorkSpace/xdbamp/xdbamp_gitcode/src# 
	(xdbamq_env) root@robert-Ubuntu:/media/sf_WorkSpace/xdbamp/xdbamp_gitcode/src# python manage.py makemigrations
	DEBUG 2020-03-06 18:55:33,547 5065 139834795271936 utils 89 Line (0.001) SET SQL_AUTO_IS_NULL = 0; args=None
	Migrations for 'workorder':
	  0001_initial.py:
		- Create model DbWorkOrder
		- Create model MyUser
	(xdbamq_env) root@robert-Ubuntu:/media/sf_WorkSpace/xdbamp/xdbamp_gitcode/src# 
	(xdbamq_env) root@robert-Ubuntu:/media/sf_WorkSpace/xdbamp/xdbamp_gitcode/src# 
	(xdbamq_env) root@robert-Ubuntu:/media/sf_WorkSpace/xdbamp/xdbamp_gitcode/src# 

4.执行 migrate 应用迁移脚本:
	(xdbamq_env) root@robert-Ubuntu:/media/sf_WorkSpace/xdbamp/xdbamp_gitcode/src# python manage.py migrate
	DEBUG 2020-03-06 19:01:29,461 5088 140417040836352 utils 89 Line (0.000) SET SQL_AUTO_IS_NULL = 0; args=None
	DEBUG 2020-03-06 19:01:29,508 5088 140417040836352 utils 89 Line (0.000) SET SQL_AUTO_IS_NULL = 0; args=None
	DEBUG 2020-03-06 19:01:29,515 5088 140417040836352 utils 89 Line (0.007) SHOW FULL TABLES; args=None
	DEBUG 2020-03-06 19:01:29,522 5088 140417040836352 utils 89 Line (0.003) SELECT `django_migrations`.`app`, `django_migrations`.`name` FROM `django_migrations`; args=()
	Operations to perform:
	  Synchronize unmigrated apps: staticfiles, rest_framework, django_filters, messages
	  Apply all migrations: admin, contenttypes, workorder, auth, sessions
	Synchronizing apps without migrations:
	DEBUG 2020-03-06 19:01:29,531 5088 140417040836352 utils 89 Line (0.005) SHOW FULL TABLES; args=None
	  Creating tables...
		Running deferred SQL...
	  Installing custom SQL...
	DEBUG 2020-03-06 19:01:29,573 5088 140417040836352 utils 89 Line (0.000) SET SQL_AUTO_IS_NULL = 0; args=None
	DEBUG 2020-03-06 19:01:29,585 5088 140417040836352 utils 89 Line (0.000) SET SQL_AUTO_IS_NULL = 0; args=None
	DEBUG 2020-03-06 19:01:29,599 5088 140417040836352 utils 89 Line (0.000) SET SQL_AUTO_IS_NULL = 0; args=None
	Running migrations:
	  Rendering model states... DONE
	  Applying contenttypes.0001_initial...DEBUG 2020-03-06 19:01:29,725 5088 140417040836352 schema 102 Line CREATE TABLE `django_content_type` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` varchar(100) NOT NULL, `app_label` varchar(100) NOT NULL, `model` varchar(100) NOT NULL); (params None)
	DEBUG 2020-03-06 19:01:29,735 5088 140417040836352 utils 89 Line (0.001) SET SQL_AUTO_IS_NULL = 0; args=None
	DEBUG 2020-03-06 19:01:29,963 5088 140417040836352 utils 89 Line (0.227) CREATE TABLE `django_content_type` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` varchar(100) NOT NULL, `app_label` varchar(100) NOT NULL, `model` varchar(100) NOT NULL); args=None
	DEBUG 2020-03-06 19:01:29,967 5088 140417040836352 utils 89 Line (0.002) SELECT engine FROM information_schema.tables WHERE table_name = 'django_content_type'; args=[u'django_content_type']
	DEBUG 2020-03-06 19:01:29,977 5088 140417040836352 schema 102 Line ALTER TABLE `django_content_type` ADD CONSTRAINT `django_content_type_app_label_45f3b1d93ec8c61c_uniq` UNIQUE (`app_label`, `model`); (params [])
	DEBUG 2020-03-06 19:01:30,205 5088 140417040836352 utils 89 Line (0.228) ALTER TABLE `django_content_type` ADD CONSTRAINT `django_content_type_app_label_45f3b1d93ec8c61c_uniq` UNIQUE (`app_label`, `model`); args=[]
	DEBUG 2020-03-06 19:01:30,210 5088 140417040836352 utils 89 Line (0.003) SHOW FULL TABLES; args=None
	DEBUG 2020-03-06 19:01:30,214 5088 140417040836352 utils 89 Line (0.002) INSERT INTO `django_migrations` (`app`, `name`, `applied`) VALUES ('contenttypes', '0001_initial', '2020-03-06 11:01:30.211505'); args=['contenttypes', u'0001_initial', u'2020-03-06 11:01:30.211505']
	 OK
	  Applying contenttypes.0002_remove_content_type_name...DEBUG 2020-03-06 19:01:30,267 5088 140417040836352 schema 102 Line ALTER TABLE `django_content_type` MODIFY `name` varchar(100) NULL; (params [])
	DEBUG 2020-03-06 19:01:30,837 5088 140417040836352 utils 89 Line (0.567) ALTER TABLE `django_content_type` MODIFY `name` varchar(100) NULL; args=[]
	DEBUG 2020-03-06 19:01:30,844 5088 140417040836352 schema 102 Line ALTER TABLE `django_content_type` DROP COLUMN `name` CASCADE; (params [])
	DEBUG 2020-03-06 19:01:31,380 5088 140417040836352 utils 89 Line (0.535) ALTER TABLE `django_content_type` DROP COLUMN `name` CASCADE; args=[]
	DEBUG 2020-03-06 19:01:31,383 5088 140417040836352 utils 89 Line (0.002) SHOW FULL TABLES; args=None
	DEBUG 2020-03-06 19:01:31,390 5088 140417040836352 utils 89 Line (0.001) INSERT INTO `django_migrations` (`app`, `name`, `applied`) VALUES ('contenttypes', '0002_remove_content_type_name', '2020-03-06 11:01:31.387955'); args=['contenttypes', u'0002_remove_content_type_name', u'2020-03-06 11:01:31.387955']
	 OK
	  Applying auth.0001_initial...DEBUG 2020-03-06 19:01:31,454 5088 140417040836352 schema 102 Line CREATE TABLE `auth_permission` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` varchar(50) NOT NULL, `content_type_id` integer NOT NULL, `codename` varchar(100) NOT NULL, UNIQUE (`content_type_id`, `codename`)); (params None)
	DEBUG 2020-03-06 19:01:31,772 5088 140417040836352 utils 89 Line (0.317) CREATE TABLE `auth_permission` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` varchar(50) NOT NULL, `content_type_id` integer NOT NULL, `codename` varchar(100) NOT NULL, UNIQUE (`content_type_id`, `codename`)); args=None
	DEBUG 2020-03-06 19:01:31,778 5088 140417040836352 utils 89 Line (0.003) SELECT engine FROM information_schema.tables WHERE table_name = 'auth_permission'; args=[u'auth_permission']
	DEBUG 2020-03-06 19:01:31,796 5088 140417040836352 schema 102 Line CREATE TABLE `auth_group` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` varchar(80) NOT NULL UNIQUE); (params None)
	DEBUG 2020-03-06 19:01:32,090 5088 140417040836352 utils 89 Line (0.292) CREATE TABLE `auth_group` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` varchar(80) NOT NULL UNIQUE); args=None
	DEBUG 2020-03-06 19:01:32,095 5088 140417040836352 utils 89 Line (0.003) SELECT engine FROM information_schema.tables WHERE table_name = 'auth_group'; args=[u'auth_group']
	DEBUG 2020-03-06 19:01:32,104 5088 140417040836352 schema 102 Line CREATE TABLE `auth_group_permissions` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `group_id` integer NOT NULL, `permission_id` integer NOT NULL, UNIQUE (`group_id`, `permission_id`)); (params None)
	DEBUG 2020-03-06 19:01:32,414 5088 140417040836352 utils 89 Line (0.306) CREATE TABLE `auth_group_permissions` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `group_id` integer NOT NULL, `permission_id` integer NOT NULL, UNIQUE (`group_id`, `permission_id`)); args=None
	DEBUG 2020-03-06 19:01:32,416 5088 140417040836352 utils 89 Line (0.002) SELECT engine FROM information_schema.tables WHERE table_name = 'auth_group_permissions'; args=[u'auth_group_permissions']
	DEBUG 2020-03-06 19:01:32,429 5088 140417040836352 schema 102 Line ALTER TABLE `auth_permission` ADD CONSTRAINT `auth__content_type_id_508cf46651277a81_fk_django_content_type_id` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`); (params [])
	DEBUG 2020-03-06 19:01:33,263 5088 140417040836352 utils 89 Line (0.833) ALTER TABLE `auth_permission` ADD CONSTRAINT `auth__content_type_id_508cf46651277a81_fk_django_content_type_id` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`); args=[]
	DEBUG 2020-03-06 19:01:33,264 5088 140417040836352 schema 102 Line ALTER TABLE `auth_group_permissions` ADD CONSTRAINT `auth_group_permission_group_id_689710a9a73b7457_fk_auth_group_id` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`); (params [])
	DEBUG 2020-03-06 19:01:34,090 5088 140417040836352 utils 89 Line (0.825) ALTER TABLE `auth_group_permissions` ADD CONSTRAINT `auth_group_permission_group_id_689710a9a73b7457_fk_auth_group_id` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`); args=[]
	DEBUG 2020-03-06 19:01:34,091 5088 140417040836352 schema 102 Line ALTER TABLE `auth_group_permissions` ADD CONSTRAINT `auth_group__permission_id_1f49ccbbdc69d2fc_fk_auth_permission_id` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`); (params [])
	DEBUG 2020-03-06 19:01:34,757 5088 140417040836352 utils 89 Line (0.665) ALTER TABLE `auth_group_permissions` ADD CONSTRAINT `auth_group__permission_id_1f49ccbbdc69d2fc_fk_auth_permission_id` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`); args=[]
	DEBUG 2020-03-06 19:01:34,777 5088 140417040836352 utils 89 Line (0.019) SHOW FULL TABLES; args=None
	DEBUG 2020-03-06 19:01:34,780 5088 140417040836352 utils 89 Line (0.001) INSERT INTO `django_migrations` (`app`, `name`, `applied`) VALUES ('auth', '0001_initial', '2020-03-06 11:01:34.778279'); args=['auth', u'0001_initial', u'2020-03-06 11:01:34.778279']
	 OK
	  Applying auth.0002_alter_permission_name_max_length...DEBUG 2020-03-06 19:01:34,831 5088 140417040836352 schema 102 Line ALTER TABLE `auth_permission` MODIFY `name` varchar(255) NOT NULL; (params [])
	DEBUG 2020-03-06 19:01:35,657 5088 140417040836352 utils 89 Line (0.825) ALTER TABLE `auth_permission` MODIFY `name` varchar(255) NOT NULL; args=[]
	DEBUG 2020-03-06 19:01:35,673 5088 140417040836352 utils 89 Line (0.015) SHOW FULL TABLES; args=None
	DEBUG 2020-03-06 19:01:35,679 5088 140417040836352 utils 89 Line (0.002) INSERT INTO `django_migrations` (`app`, `name`, `applied`) VALUES ('auth', '0002_alter_permission_name_max_length', '2020-03-06 11:01:35.675754'); args=['auth', u'0002_alter_permission_name_max_length', u'2020-03-06 11:01:35.675754']
	 OK
	  Applying auth.0003_alter_user_email_max_length...DEBUG 2020-03-06 19:01:35,722 5088 140417040836352 utils 89 Line (0.004) SHOW FULL TABLES; args=None
	DEBUG 2020-03-06 19:01:35,727 5088 140417040836352 utils 89 Line (0.001) INSERT INTO `django_migrations` (`app`, `name`, `applied`) VALUES ('auth', '0003_alter_user_email_max_length', '2020-03-06 11:01:35.725494'); args=['auth', u'0003_alter_user_email_max_length', u'2020-03-06 11:01:35.725494']
	 OK
	  Applying auth.0004_alter_user_username_opts...DEBUG 2020-03-06 19:01:35,778 5088 140417040836352 utils 89 Line (0.003) SHOW FULL TABLES; args=None
	DEBUG 2020-03-06 19:01:35,781 5088 140417040836352 utils 89 Line (0.001) INSERT INTO `django_migrations` (`app`, `name`, `applied`) VALUES ('auth', '0004_alter_user_username_opts', '2020-03-06 11:01:35.779641'); args=['auth', u'0004_alter_user_username_opts', u'2020-03-06 11:01:35.779641']
	 OK
	  Applying auth.0005_alter_user_last_login_null...DEBUG 2020-03-06 19:01:35,826 5088 140417040836352 utils 89 Line (0.004) SHOW FULL TABLES; args=None
	DEBUG 2020-03-06 19:01:35,833 5088 140417040836352 utils 89 Line (0.001) INSERT INTO `django_migrations` (`app`, `name`, `applied`) VALUES ('auth', '0005_alter_user_last_login_null', '2020-03-06 11:01:35.829804'); args=['auth', u'0005_alter_user_last_login_null', u'2020-03-06 11:01:35.829804']
	 OK
	  Applying auth.0006_require_contenttypes_0002...DEBUG 2020-03-06 19:01:35,879 5088 140417040836352 utils 89 Line (0.004) SHOW FULL TABLES; args=None
	DEBUG 2020-03-06 19:01:35,883 5088 140417040836352 utils 89 Line (0.001) INSERT INTO `django_migrations` (`app`, `name`, `applied`) VALUES ('auth', '0006_require_contenttypes_0002', '2020-03-06 11:01:35.881388'); args=['auth', u'0006_require_contenttypes_0002', u'2020-03-06 11:01:35.881388']
	 OK
	  Applying workorder.0001_initial...DEBUG 2020-03-06 19:01:35,949 5088 140417040836352 schema 102 Line CREATE TABLE `myuser` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `password` varchar(128) NOT NULL, `last_login` datetime(6) NULL, `is_superuser` bool NOT NULL, `username` varchar(30) NOT NULL UNIQUE, `first_name` varchar(30) NOT NULL, `last_name` varchar(30) NOT NULL, `email` varchar(254) NOT NULL, `is_staff` bool NOT NULL, `is_active` bool NOT NULL, `date_joined` datetime(6) NOT NULL, `dept_name` varchar(256) NOT NULL); (params None)
	DEBUG 2020-03-06 19:01:36,200 5088 140417040836352 utils 89 Line (0.249) CREATE TABLE `myuser` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `password` varchar(128) NOT NULL, `last_login` datetime(6) NULL, `is_superuser` bool NOT NULL, `username` varchar(30) NOT NULL UNIQUE, `first_name` varchar(30) NOT NULL, `last_name` varchar(30) NOT NULL, `email` varchar(254) NOT NULL, `is_staff` bool NOT NULL, `is_active` bool NOT NULL, `date_joined` datetime(6) NOT NULL, `dept_name` varchar(256) NOT NULL); args=None
	DEBUG 2020-03-06 19:01:36,209 5088 140417040836352 utils 89 Line (0.006) SELECT engine FROM information_schema.tables WHERE table_name = 'myuser'; args=[u'myuser']
	DEBUG 2020-03-06 19:01:36,213 5088 140417040836352 schema 102 Line CREATE TABLE `myuser_groups` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `myuser_id` integer NOT NULL, `group_id` integer NOT NULL, UNIQUE (`myuser_id`, `group_id`)); (params None)
	DEBUG 2020-03-06 19:01:36,471 5088 140417040836352 utils 89 Line (0.255) CREATE TABLE `myuser_groups` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `myuser_id` integer NOT NULL, `group_id` integer NOT NULL, UNIQUE (`myuser_id`, `group_id`)); args=None
	DEBUG 2020-03-06 19:01:36,475 5088 140417040836352 utils 89 Line (0.002) SELECT engine FROM information_schema.tables WHERE table_name = 'myuser_groups'; args=[u'myuser_groups']
	DEBUG 2020-03-06 19:01:36,477 5088 140417040836352 schema 102 Line CREATE TABLE `myuser_user_permissions` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `myuser_id` integer NOT NULL, `permission_id` integer NOT NULL, UNIQUE (`myuser_id`, `permission_id`)); (params None)
	DEBUG 2020-03-06 19:01:37,007 5088 140417040836352 utils 89 Line (0.529) CREATE TABLE `myuser_user_permissions` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `myuser_id` integer NOT NULL, `permission_id` integer NOT NULL, UNIQUE (`myuser_id`, `permission_id`)); args=None
	DEBUG 2020-03-06 19:01:37,010 5088 140417040836352 utils 89 Line (0.002) SELECT engine FROM information_schema.tables WHERE table_name = 'myuser_user_permissions'; args=[u'myuser_user_permissions']
	DEBUG 2020-03-06 19:01:37,011 5088 140417040836352 schema 102 Line ALTER TABLE `myuser_groups` ADD CONSTRAINT `myuser_groups_myuser_id_1175cd02394be8e4_fk_myuser_id` FOREIGN KEY (`myuser_id`) REFERENCES `myuser` (`id`); (params [])
	DEBUG 2020-03-06 19:01:37,879 5088 140417040836352 utils 89 Line (0.867) ALTER TABLE `myuser_groups` ADD CONSTRAINT `myuser_groups_myuser_id_1175cd02394be8e4_fk_myuser_id` FOREIGN KEY (`myuser_id`) REFERENCES `myuser` (`id`); args=[]
	DEBUG 2020-03-06 19:01:37,880 5088 140417040836352 schema 102 Line ALTER TABLE `myuser_groups` ADD CONSTRAINT `myuser_groups_group_id_1e9663349f32b407_fk_auth_group_id` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`); (params [])
	DEBUG 2020-03-06 19:01:39,013 5088 140417040836352 utils 89 Line (1.132) ALTER TABLE `myuser_groups` ADD CONSTRAINT `myuser_groups_group_id_1e9663349f32b407_fk_auth_group_id` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`); args=[]
	DEBUG 2020-03-06 19:01:39,014 5088 140417040836352 schema 102 Line ALTER TABLE `myuser_user_permissions` ADD CONSTRAINT `myuser_user_permissions_myuser_id_3fd4ec53139c41f6_fk_myuser_id` FOREIGN KEY (`myuser_id`) REFERENCES `myuser` (`id`); (params [])
	DEBUG 2020-03-06 19:01:40,217 5088 140417040836352 utils 89 Line (1.202) ALTER TABLE `myuser_user_permissions` ADD CONSTRAINT `myuser_user_permissions_myuser_id_3fd4ec53139c41f6_fk_myuser_id` FOREIGN KEY (`myuser_id`) REFERENCES `myuser` (`id`); args=[]
	DEBUG 2020-03-06 19:01:40,218 5088 140417040836352 schema 102 Line ALTER TABLE `myuser_user_permissions` ADD CONSTRAINT `myuser_user_permission_id_7cc4542c824d8b08_fk_auth_permission_id` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`); (params [])
	DEBUG 2020-03-06 19:01:41,480 5088 140417040836352 utils 89 Line (1.261) ALTER TABLE `myuser_user_permissions` ADD CONSTRAINT `myuser_user_permission_id_7cc4542c824d8b08_fk_auth_permission_id` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`); args=[]
	DEBUG 2020-03-06 19:01:41,511 5088 140417040836352 utils 89 Line (0.026) SHOW FULL TABLES; args=None
	DEBUG 2020-03-06 19:01:41,535 5088 140417040836352 utils 89 Line (0.021) INSERT INTO `django_migrations` (`app`, `name`, `applied`) VALUES ('workorder', '0001_initial', '2020-03-06 11:01:41.513223'); args=['workorder', u'0001_initial', u'2020-03-06 11:01:41.513223']
	 OK
	  Applying admin.0001_initial...DEBUG 2020-03-06 19:01:41,623 5088 140417040836352 schema 102 Line CREATE TABLE `django_admin_log` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `action_time` datetime(6) NOT NULL, `object_id` longtext NULL, `object_repr` varchar(200) NOT NULL, `action_flag` smallint UNSIGNED NOT NULL, `change_message` longtext NOT NULL, `content_type_id` integer NULL, `user_id` integer NOT NULL); (params None)
	DEBUG 2020-03-06 19:01:42,047 5088 140417040836352 utils 89 Line (0.421) CREATE TABLE `django_admin_log` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `action_time` datetime(6) NOT NULL, `object_id` longtext NULL, `object_repr` varchar(200) NOT NULL, `action_flag` smallint UNSIGNED NOT NULL, `change_message` longtext NOT NULL, `content_type_id` integer NULL, `user_id` integer NOT NULL); args=None
	DEBUG 2020-03-06 19:01:42,052 5088 140417040836352 utils 89 Line (0.004) SELECT engine FROM information_schema.tables WHERE table_name = 'django_admin_log'; args=[u'django_admin_log']
	DEBUG 2020-03-06 19:01:42,054 5088 140417040836352 schema 102 Line ALTER TABLE `django_admin_log` ADD CONSTRAINT `djang_content_type_id_697914295151027a_fk_django_content_type_id` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`); (params [])
	DEBUG 2020-03-06 19:01:43,599 5088 140417040836352 utils 89 Line (1.543) ALTER TABLE `django_admin_log` ADD CONSTRAINT `djang_content_type_id_697914295151027a_fk_django_content_type_id` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`); args=[]
	DEBUG 2020-03-06 19:01:43,600 5088 140417040836352 schema 102 Line ALTER TABLE `django_admin_log` ADD CONSTRAINT `django_admin_log_user_id_52fdd58701c5f563_fk_myuser_id` FOREIGN KEY (`user_id`) REFERENCES `myuser` (`id`); (params [])
	DEBUG 2020-03-06 19:01:44,429 5088 140417040836352 utils 89 Line (0.829) ALTER TABLE `django_admin_log` ADD CONSTRAINT `django_admin_log_user_id_52fdd58701c5f563_fk_myuser_id` FOREIGN KEY (`user_id`) REFERENCES `myuser` (`id`); args=[]
	DEBUG 2020-03-06 19:01:44,445 5088 140417040836352 utils 89 Line (0.015) SHOW FULL TABLES; args=None
	DEBUG 2020-03-06 19:01:44,448 5088 140417040836352 utils 89 Line (0.001) INSERT INTO `django_migrations` (`app`, `name`, `applied`) VALUES ('admin', '0001_initial', '2020-03-06 11:01:44.446422'); args=['admin', u'0001_initial', u'2020-03-06 11:01:44.446422']
	 OK
	  Applying sessions.0001_initial...DEBUG 2020-03-06 19:01:44,492 5088 140417040836352 schema 102 Line CREATE TABLE `django_session` (`session_key` varchar(40) NOT NULL PRIMARY KEY, `session_data` longtext NOT NULL, `expire_date` datetime(6) NOT NULL); (params None)
	DEBUG 2020-03-06 19:01:44,775 5088 140417040836352 utils 89 Line (0.276) CREATE TABLE `django_session` (`session_key` varchar(40) NOT NULL PRIMARY KEY, `session_data` longtext NOT NULL, `expire_date` datetime(6) NOT NULL); args=None
	DEBUG 2020-03-06 19:01:44,783 5088 140417040836352 utils 89 Line (0.005) SELECT engine FROM information_schema.tables WHERE table_name = 'django_session'; args=[u'django_session']
	DEBUG 2020-03-06 19:01:44,787 5088 140417040836352 schema 102 Line CREATE INDEX `django_session_de54fa62` ON `django_session` (`expire_date`); (params [])
	DEBUG 2020-03-06 19:01:45,028 5088 140417040836352 utils 89 Line (0.239) CREATE INDEX `django_session_de54fa62` ON `django_session` (`expire_date`); args=[]
	DEBUG 2020-03-06 19:01:45,030 5088 140417040836352 utils 89 Line (0.002) SHOW FULL TABLES; args=None
	DEBUG 2020-03-06 19:01:45,050 5088 140417040836352 utils 89 Line (0.014) INSERT INTO `django_migrations` (`app`, `name`, `applied`) VALUES ('sessions', '0001_initial', '2020-03-06 11:01:45.031821'); args=['sessions', u'0001_initial', u'2020-03-06 11:01:45.031821']
	 OK
	DEBUG 2020-03-06 19:01:45,087 5088 140417040836352 utils 89 Line (0.003) SHOW FULL TABLES; args=None
	DEBUG 2020-03-06 19:01:45,096 5088 140417040836352 utils 89 Line (0.001) SELECT `django_migrations`.`app`, `django_migrations`.`name` FROM `django_migrations`; args=()
	DEBUG 2020-03-06 19:01:45,126 5088 140417040836352 utils 89 Line (0.027) SELECT `django_content_type`.`id`, `django_content_type`.`app_label`, `django_content_type`.`model` FROM `django_content_type` WHERE (`django_content_type`.`model` = 'logentry' AND `django_content_type`.`app_label` = 'admin'); args=('logentry', 'admin')
	DEBUG 2020-03-06 19:01:45,129 5088 140417040836352 utils 89 Line (0.001) SELECT `django_content_type`.`id`, `django_content_type`.`app_label`, `django_content_type`.`model` FROM `django_content_type` WHERE (`django_content_type`.`model` = 'logentry' AND `django_content_type`.`app_label` = 'admin'); args=('logentry', 'admin')
	DEBUG 2020-03-06 19:01:45,140 5088 140417040836352 utils 89 Line (0.009) INSERT INTO `django_content_type` (`app_label`, `model`) VALUES ('admin', 'logentry'); args=['admin', 'logentry']
	DEBUG 2020-03-06 19:01:45,271 5088 140417040836352 utils 89 Line (0.032) SELECT `auth_permission`.`content_type_id`, `auth_permission`.`codename` FROM `auth_permission` INNER JOIN `django_content_type` ON ( `auth_permission`.`content_type_id` = `django_content_type`.`id` ) WHERE `auth_permission`.`content_type_id` IN (1) ORDER BY `django_content_type`.`app_label` ASC, `django_content_type`.`model` ASC, `auth_permission`.`codename` ASC; args=(1,)
	DEBUG 2020-03-06 19:01:45,276 5088 140417040836352 utils 89 Line (0.002) INSERT INTO `auth_permission` (`name`, `content_type_id`, `codename`) VALUES ('Can add log entry', 1, 'add_logentry'), ('Can change log entry', 1, 'change_logentry'), ('Can delete log entry', 1, 'delete_logentry'); args=(u'Can add log entry', 1, u'add_logentry', u'Can change log entry', 1, u'change_logentry', u'Can delete log entry', 1, u'delete_logentry')
	DEBUG 2020-03-06 19:01:45,319 5088 140417040836352 utils 89 Line (0.001) SELECT `django_content_type`.`id`, `django_content_type`.`app_label`, `django_content_type`.`model` FROM `django_content_type` WHERE `django_content_type`.`app_label` = 'admin'; args=('admin',)
	DEBUG 2020-03-06 19:01:45,322 5088 140417040836352 utils 89 Line (0.001) SELECT `django_content_type`.`id`, `django_content_type`.`app_label`, `django_content_type`.`model` FROM `django_content_type` WHERE (`django_content_type`.`model` = 'permission' AND `django_content_type`.`app_label` = 'auth'); args=('permission', 'auth')
	DEBUG 2020-03-06 19:01:45,327 5088 140417040836352 utils 89 Line (0.001) SELECT `django_content_type`.`id`, `django_content_type`.`app_label`, `django_content_type`.`model` FROM `django_content_type` WHERE (`django_content_type`.`model` = 'permission' AND `django_content_type`.`app_label` = 'auth'); args=('permission', 'auth')
	DEBUG 2020-03-06 19:01:45,356 5088 140417040836352 utils 89 Line (0.027) INSERT INTO `django_content_type` (`app_label`, `model`) VALUES ('auth', 'permission'); args=['auth', 'permission']
	DEBUG 2020-03-06 19:01:45,418 5088 140417040836352 utils 89 Line (0.001) SELECT `django_content_type`.`id`, `django_content_type`.`app_label`, `django_content_type`.`model` FROM `django_content_type` WHERE (`django_content_type`.`model` = 'group' AND `django_content_type`.`app_label` = 'auth'); args=('group', 'auth')
	DEBUG 2020-03-06 19:01:45,420 5088 140417040836352 utils 89 Line (0.001) SELECT `django_content_type`.`id`, `django_content_type`.`app_label`, `django_content_type`.`model` FROM `django_content_type` WHERE (`django_content_type`.`model` = 'group' AND `django_content_type`.`app_label` = 'auth'); args=('group', 'auth')
	DEBUG 2020-03-06 19:01:45,435 5088 140417040836352 utils 89 Line (0.012) INSERT INTO `django_content_type` (`app_label`, `model`) VALUES ('auth', 'group'); args=['auth', 'group']
	DEBUG 2020-03-06 19:01:45,478 5088 140417040836352 utils 89 Line (0.001) SELECT `auth_permission`.`content_type_id`, `auth_permission`.`codename` FROM `auth_permission` INNER JOIN `django_content_type` ON ( `auth_permission`.`content_type_id` = `django_content_type`.`id` ) WHERE `auth_permission`.`content_type_id` IN (2, 3) ORDER BY `django_content_type`.`app_label` ASC, `django_content_type`.`model` ASC, `auth_permission`.`codename` ASC; args=(2, 3)
	DEBUG 2020-03-06 19:01:45,494 5088 140417040836352 utils 89 Line (0.012) INSERT INTO `auth_permission` (`name`, `content_type_id`, `codename`) VALUES ('Can add permission', 2, 'add_permission'), ('Can change permission', 2, 'change_permission'), ('Can delete permission', 2, 'delete_permission'), ('Can add group', 3, 'add_group'), ('Can change group', 3, 'change_group'), ('Can delete group', 3, 'delete_group'); args=(u'Can add permission', 2, u'add_permission', u'Can change permission', 2, u'change_permission', u'Can delete permission', 2, u'delete_permission', u'Can add group', 3, u'add_group', u'Can change group', 3, u'change_group', u'Can delete group', 3, u'delete_group')
	DEBUG 2020-03-06 19:01:45,537 5088 140417040836352 utils 89 Line (0.001) SELECT `django_content_type`.`id`, `django_content_type`.`app_label`, `django_content_type`.`model` FROM `django_content_type` WHERE `django_content_type`.`app_label` = 'auth'; args=('auth',)
	DEBUG 2020-03-06 19:01:45,542 5088 140417040836352 utils 89 Line (0.001) SELECT `django_content_type`.`id`, `django_content_type`.`app_label`, `django_content_type`.`model` FROM `django_content_type` WHERE (`django_content_type`.`model` = 'contenttype' AND `django_content_type`.`app_label` = 'contenttypes'); args=('contenttype', 'contenttypes')
	DEBUG 2020-03-06 19:01:45,546 5088 140417040836352 utils 89 Line (0.001) SELECT `django_content_type`.`id`, `django_content_type`.`app_label`, `django_content_type`.`model` FROM `django_content_type` WHERE (`django_content_type`.`model` = 'contenttype' AND `django_content_type`.`app_label` = 'contenttypes'); args=('contenttype', 'contenttypes')
	DEBUG 2020-03-06 19:01:45,550 5088 140417040836352 utils 89 Line (0.001) INSERT INTO `django_content_type` (`app_label`, `model`) VALUES ('contenttypes', 'contenttype'); args=['contenttypes', 'contenttype']
	DEBUG 2020-03-06 19:01:45,585 5088 140417040836352 utils 89 Line (0.001) SELECT `auth_permission`.`content_type_id`, `auth_permission`.`codename` FROM `auth_permission` INNER JOIN `django_content_type` ON ( `auth_permission`.`content_type_id` = `django_content_type`.`id` ) WHERE `auth_permission`.`content_type_id` IN (4) ORDER BY `django_content_type`.`app_label` ASC, `django_content_type`.`model` ASC, `auth_permission`.`codename` ASC; args=(4,)
	DEBUG 2020-03-06 19:01:45,613 5088 140417040836352 utils 89 Line (0.025) INSERT INTO `auth_permission` (`name`, `content_type_id`, `codename`) VALUES ('Can add content type', 4, 'add_contenttype'), ('Can change content type', 4, 'change_contenttype'), ('Can delete content type', 4, 'delete_contenttype'); args=(u'Can add content type', 4, u'add_contenttype', u'Can change content type', 4, u'change_contenttype', u'Can delete content type', 4, u'delete_contenttype')
	DEBUG 2020-03-06 19:01:45,739 5088 140417040836352 utils 89 Line (0.001) SELECT `django_content_type`.`id`, `django_content_type`.`app_label`, `django_content_type`.`model` FROM `django_content_type` WHERE `django_content_type`.`app_label` = 'contenttypes'; args=('contenttypes',)
	DEBUG 2020-03-06 19:01:45,741 5088 140417040836352 utils 89 Line (0.001) SELECT `django_content_type`.`id`, `django_content_type`.`app_label`, `django_content_type`.`model` FROM `django_content_type` WHERE (`django_content_type`.`model` = 'session' AND `django_content_type`.`app_label` = 'sessions'); args=('session', 'sessions')
	DEBUG 2020-03-06 19:01:45,746 5088 140417040836352 utils 89 Line (0.002) SELECT `django_content_type`.`id`, `django_content_type`.`app_label`, `django_content_type`.`model` FROM `django_content_type` WHERE (`django_content_type`.`model` = 'session' AND `django_content_type`.`app_label` = 'sessions'); args=('session', 'sessions')
	DEBUG 2020-03-06 19:01:45,759 5088 140417040836352 utils 89 Line (0.010) INSERT INTO `django_content_type` (`app_label`, `model`) VALUES ('sessions', 'session'); args=['sessions', 'session']
	DEBUG 2020-03-06 19:01:45,794 5088 140417040836352 utils 89 Line (0.001) SELECT `auth_permission`.`content_type_id`, `auth_permission`.`codename` FROM `auth_permission` INNER JOIN `django_content_type` ON ( `auth_permission`.`content_type_id` = `django_content_type`.`id` ) WHERE `auth_permission`.`content_type_id` IN (5) ORDER BY `django_content_type`.`app_label` ASC, `django_content_type`.`model` ASC, `auth_permission`.`codename` ASC; args=(5,)
	DEBUG 2020-03-06 19:01:45,797 5088 140417040836352 utils 89 Line (0.001) INSERT INTO `auth_permission` (`name`, `content_type_id`, `codename`) VALUES ('Can add session', 5, 'add_session'), ('Can change session', 5, 'change_session'), ('Can delete session', 5, 'delete_session'); args=(u'Can add session', 5, u'add_session', u'Can change session', 5, u'change_session', u'Can delete session', 5, u'delete_session')
	DEBUG 2020-03-06 19:01:45,831 5088 140417040836352 utils 89 Line (0.001) SELECT `django_content_type`.`id`, `django_content_type`.`app_label`, `django_content_type`.`model` FROM `django_content_type` WHERE `django_content_type`.`app_label` = 'sessions'; args=('sessions',)
	DEBUG 2020-03-06 19:01:45,837 5088 140417040836352 utils 89 Line (0.001) SELECT `django_content_type`.`id`, `django_content_type`.`app_label`, `django_content_type`.`model` FROM `django_content_type` WHERE (`django_content_type`.`model` = 'myuser' AND `django_content_type`.`app_label` = 'workorder'); args=('myuser', 'workorder')
	DEBUG 2020-03-06 19:01:45,845 5088 140417040836352 utils 89 Line (0.004) SELECT `django_content_type`.`id`, `django_content_type`.`app_label`, `django_content_type`.`model` FROM `django_content_type` WHERE (`django_content_type`.`model` = 'myuser' AND `django_content_type`.`app_label` = 'workorder'); args=('myuser', 'workorder')
	DEBUG 2020-03-06 19:01:45,850 5088 140417040836352 utils 89 Line (0.001) INSERT INTO `django_content_type` (`app_label`, `model`) VALUES ('workorder', 'myuser'); args=['workorder', 'myuser']
	DEBUG 2020-03-06 19:01:45,885 5088 140417040836352 utils 89 Line (0.001) SELECT `django_content_type`.`id`, `django_content_type`.`app_label`, `django_content_type`.`model` FROM `django_content_type` WHERE (`django_content_type`.`model` = 'dbworkorder' AND `django_content_type`.`app_label` = 'workorder'); args=('dbworkorder', 'workorder')
	DEBUG 2020-03-06 19:01:45,887 5088 140417040836352 utils 89 Line (0.001) SELECT `django_content_type`.`id`, `django_content_type`.`app_label`, `django_content_type`.`model` FROM `django_content_type` WHERE (`django_content_type`.`model` = 'dbworkorder' AND `django_content_type`.`app_label` = 'workorder'); args=('dbworkorder', 'workorder')
	DEBUG 2020-03-06 19:01:45,892 5088 140417040836352 utils 89 Line (0.002) INSERT INTO `django_content_type` (`app_label`, `model`) VALUES ('workorder', 'dbworkorder'); args=['workorder', 'dbworkorder']
	DEBUG 2020-03-06 19:01:45,923 5088 140417040836352 utils 89 Line (0.001) SELECT `auth_permission`.`content_type_id`, `auth_permission`.`codename` FROM `auth_permission` INNER JOIN `django_content_type` ON ( `auth_permission`.`content_type_id` = `django_content_type`.`id` ) WHERE `auth_permission`.`content_type_id` IN (6, 7) ORDER BY `django_content_type`.`app_label` ASC, `django_content_type`.`model` ASC, `auth_permission`.`codename` ASC; args=(6, 7)
	DEBUG 2020-03-06 19:01:45,927 5088 140417040836352 utils 89 Line (0.001) INSERT INTO `auth_permission` (`name`, `content_type_id`, `codename`) VALUES ('Can add my user', 6, 'add_myuser'), ('Can change my user', 6, 'change_myuser'), ('Can delete my user', 6, 'delete_myuser'), ('Can add db work order', 7, 'add_dbworkorder'), ('Can change db work order', 7, 'change_dbworkorder'), ('Can delete db work order', 7, 'delete_dbworkorder'); args=(u'Can add my user', 6, u'add_myuser', u'Can change my user', 6, u'change_myuser', u'Can delete my user', 6, u'delete_myuser', u'Can add db work order', 7, u'add_dbworkorder', u'Can change db work order', 7, u'change_dbworkorder', u'Can delete db work order', 7, u'delete_dbworkorder')
	DEBUG 2020-03-06 19:01:45,960 5088 140417040836352 utils 89 Line (0.001) SELECT `django_content_type`.`id`, `django_content_type`.`app_label`, `django_content_type`.`model` FROM `django_content_type` WHERE `django_content_type`.`app_label` = 'workorder'; args=('workorder',)
	(xdbamq_env) root@robert-Ubuntu:/media/sf_WorkSpace/xdbamp/xdbamp_gitcode/src# 

5.创建 superuser 然后登陆 http://192.168.56.101:8085/admin 页面,发现看不到 Django 的原生 User 表 只剩下了原生 Group 表了
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值