ERRORS: auth.User.groups: (fields.E304) Reverse accessor 'Group.user_set'for'auth.User.groups' clashes with reverse accessor for'users.User.groups'. HINT: Add or change a related_name argument to the definition for'auth.User.groups'or'users.User.groups'. auth.User.user_permissions: (fields.E304) Reverse accessor 'Permission.user_set'for'auth.User.user_permissions' clashes with reverse accessor for'users.User.user_permissions'. HINT: Add or change a related_name argument to the definition for'auth.User.user_permissions'or'users.User.user_permissions'. users.User.groups: (fields.E304) Reverse accessor 'Group.user_set'for'users.User.groups' clashes with reverse accessor for'auth.User.groups'. HINT: Add or change a related_name argument to the definition for'users.User.groups'or'auth.User.groups'. users.User.user_permissions: (fields.E304) Reverse accessor 'Permission.user_set'for'users.User.user_permissions' clashes with reverse accessor for'auth.User.user_permissions'. HINT: Add or change a related_name argument to the definition for'users.User.user_permissions'or'auth.User.user_permissions'.
# 注意:后面不能跟 , 号,否则会报:TypeError: ForeignKey(('users.User',)) is invalid. First parameter to ForeignKey must be either a model, a model name, or the string 'self' AUTH_USER_MODEL = 'users.User'
数据迁移
1.切换到命令下,执行下列命令生成迁移记录:
1 2 3 4 5
(haoke_small) leazhi@ubuntuhome:~/small$ cd haoke/haoke/apps/ (haoke_small) leazhi@ubuntuhome:~/small/haoke/haoke/apps$ python ../../manage.py makemigrations Migrations for'users': users/migrations/0001_initial.py - Create model User
(haoke_small) leazhi@ubuntuhome:~/small/haoke/haoke/apps$ python ../../manage.py migrate Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions, users Running migrations: Applying contenttypes.0001_initial... OK Applying contenttypes.0002_remove_content_type_name... OK Applying auth.0001_initial... OK Applying auth.0002_alter_permission_name_max_length... OK Applying auth.0003_alter_user_email_max_length... OK Applying auth.0004_alter_user_username_opts... OK Applying auth.0005_alter_user_last_login_null... OK Applying auth.0006_require_contenttypes_0002... OK Applying auth.0007_alter_validators_add_error_messages... OK Applying auth.0008_alter_user_username_max_length... OK Applying auth.0009_alter_user_last_name_max_length... OK Applying auth.0010_alter_group_name_max_length... OK Applying auth.0011_update_proxy_permissions... OK Applying auth.0012_alter_user_first_name_max_length... OK Applying users.0001_initial... OK Applying admin.0001_initial... OK Applying admin.0002_logentry_remove_auto_add... OK Applying admin.0003_logentry_add_action_flag_choices... OK Applying sessions.0001_initial... OK
(haoke_small) leazhi@ubuntuhome:~/small/haoke/haoke/apps$ mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 816 Server version: 10.10.2-MariaDB-log MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h'forhelp. Type '\c' to clear the current input statement.
(root@localhost (none) 09:24:)>show databases; +--------------------+ | Database | +--------------------+ | blog | | book | | dangdang | | db1 | | db2 | | information_schema | | mysql | | performance_schema | | small | | sys | | test | +--------------------+ 11 rows inset (0.001 sec)
(root@localhost (none) 09:24:)>use small; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A