我在Django上解决了一个错误,但发生了另一个错误。 我的设置在这里 - > UnicodeDecodeError with Django when I execute syncdb
$ python manage.py makemigrations myapp
$ python manage.py migrate --database=mydj
$ python manage.py createsuperuser --database=mydj
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 351, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 343, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 394, in run_from_argv
self.execute(*args, **cmd_options)
File "/Library/Python/2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 50, in execute
return super(Command, self).execute(*args, **options)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 445, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 81, in handle
default_username = get_default_username()
File "/Library/Python/2.7/site-packages/django/contrib/auth/management/__init__.py", line 177, in get_default_username
auth_app.User._default_manager.get(username=default_username)
File "/Library/Python/2.7/site-packages/django/db/models/manager.py", line 127, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 328, in get
num = len(clone)
File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 144, in __len__
self._fetch_all()
File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 965, in _fetch_all
self._result_cache = list(self.iterator())
File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 238, in iterator
results = compiler.execute_sql()
File "/Library/Python/2.7/site-packages/django/db/models/sql/compiler.py", line 840, in execute_sql
cursor.execute(sql, params)
File "/Library/Python/2.7/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/Library/Python/2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/Library/Python/2.7/site-packages/django/db/utils.py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Library/Python/2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/Library/Python/2.7/site-packages/django/db/backends/sqlite3/base.py", line 318, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: auth_user
但是,当我查看表格时,
$ mysql -u root -p
[root@(none)]mysql> USE djdb
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
[root@djdb]mysql> SHOW TABLES FROM djdb \G
*************************** 1. row ***************************
Tables_in_djdb: auth_group
*************************** 2. row ***************************
Tables_in_djdb: auth_group_permissions
*************************** 3. row ***************************
Tables_in_djdb: auth_permission
*************************** 4. row ***************************
Tables_in_djdb: auth_user
*************************** 5. row ***************************
Tables_in_djdb: auth_user_groups
*************************** 6. row ***************************
Tables_in_djdb: auth_user_user_permissions
*************************** 7. row ***************************
Tables_in_djdb: django_admin_log
*************************** 8. row ***************************
Tables_in_djdb: django_content_type
*************************** 9. row ***************************
Tables_in_djdb: django_migrations
*************************** 10. row ***************************
Tables_in_djdb: django_session
*************************** 11. row ***************************
Tables_in_djdb: myapp_mydb
11 rows in set (0.00 sec)
[root@djdb]mysql> DESC auth_user \G
*************************** 1. row ***************************
Field: id
Type: int(11)
Null: NO
Key: PRI
Default: NULL
Extra: auto_increment
*************************** 2. row ***************************
Field: password
Type: varchar(128)
Null: NO
Key:
Default: NULL
Extra:
*************************** 3. row ***************************
Field: last_login
Type: datetime(6)
Null: YES
Key:
Default: NULL
Extra:
*************************** 4. row ***************************
Field: is_superuser
Type: tinyint(1)
Null: NO
Key:
Default: NULL
Extra:
*************************** 5. row ***************************
Field: username
Type: varchar(30)
Null: NO
Key: UNI
Default: NULL
Extra:
*************************** 6. row ***************************
Field: first_name
Type: varchar(30)
Null: NO
Key:
Default: NULL
Extra:
*************************** 7. row ***************************
Field: last_name
Type: varchar(30)
Null: NO
Key:
Default: NULL
Extra:
*************************** 8. row ***************************
Field: email
Type: varchar(254)
Null: NO
Key:
Default: NULL
Extra:
*************************** 9. row ***************************
Field: is_staff
Type: tinyint(1)
Null: NO
Key:
Default: NULL
Extra:
*************************** 10. row ***************************
Field: is_active
Type: tinyint(1)
Null: NO
Key:
Default: NULL
Extra:
*************************** 11. row ***************************
Field: date_joined
Type: datetime(6)
Null: NO
Key:
Default: NULL
Extra:
11 rows in set (0.01 sec)
我想我有auth_user表。 我该如何解决错误?
感谢。