我正在尝试在生产中创建一个超级用户,以便访问Django管理站点。但是,这样做我得到以下错误
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home4/techaven/virtualenv/myenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/home4/techaven/virtualenv/myenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home4/techaven/virtualenv/myenv/lib/python2.7/site-packages/django/core/management/base.py", line 393, in run_from_argv
self.execute(*args, **cmd_options)
File "/home4/techaven/virtualenv/myenv/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 50, in execute
return super(Command, self).execute(*args, **options)
File "/home4/techaven/virtualenv/myenv/lib/python2.7/site-packages/django/core/management/base.py", line 444, in execute
output = self.handle(*args, **options)
File "/home4/techaven/virtualenv/myenv/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 149, in handle
self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
File "/home4/techaven/virtualenv/myenv/lib/python2.7/site-packages/django/contrib/auth/models.py", line 191, in create_superuser
**extra_fields)
File "/home4/techaven/virtualenv/myenv/lib/python2.7/site-packages/django/contrib/auth/models.py", line 182, in _create_user
user.save(using=self._db)
File "/home4/techaven/virtualenv/myenv/lib/python2.7/site-packages/django/db/models/base.py", line 734, in save
force_update=force_update, update_fields=update_fields)
File "/home4/techaven/virtualenv/myenv/lib/python2.7/site-packages/django/db/models/base.py", line 762, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/home4/techaven/virtualenv/myenv/lib/python2.7/site-packages/django/db/models/base.py", line 846, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/home4/techaven/virtualenv/myenv/lib/python2.7/site-packages/django/db/models/base.py", line 885, in _do_insert
using=using, raw=raw)
File "/home4/techaven/virtualenv/myenv/lib/python2.7/site-packages/django/db/models/manager.py", line 127, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home4/techaven/virtualenv/myenv/lib/python2.7/site-packages/django/db/models/query.py", line 920, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "/home4/techaven/virtualenv/myenv/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 974, in execute_sql
cursor.execute(sql, params)
File "/home4/techaven/virtualenv/myenv/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home4/techaven/virtualenv/myenv/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 129, in execute
six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
File "/home4/techaven/virtualenv/myenv/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 124, in execute
return self.cursor.execute(query, args)
File "/opt/python27/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg/MySQLdb/cursors.py", line 174, in execute
File "/opt/python27/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg/MySQLdb/connections.py", line 36, in defaulterrorhandler
django.db.utils.IntegrityError:(1048,&#34; Column&#39; last_login&#39;不能为空&#34;)
我已经完成了syncdb并在mysql中创建了表。但是当我试图创建超级用户时,我得到了上述错误。我尝试了不同的文档,但没有关于创建超级用户以及如何解决这个问题。
非常欢迎任何线索。我在使用django时遇到了麻烦。 提前谢谢
答案 0 :(得分:0)
由于您使用的是管理员应用,请不要忘记同步所有与管理员相关的应用(例如,会话,管理员,身份验证,内容类型)。
不
python manage.py migrate myapp
可是:
python manage.py migrate