简体   繁体   English

字段“ id”没有默认值django-registration

[英]Field 'id' doesn't have a default value django-registration

I recently loaded all of the django-registration tables from sqlite into a mysql database. 我最近将所有的django注册表从sqlite加载到mysql数据库中。 It works fine for logging in users, but now when I try to register a user I get this error: 它适合登录用户,但是现在当我尝试注册用户时,出现此错误:

Warning at /accounts/register/
Field 'id' doesn't have a default value

I tried using this line to make the id field auto increment but I'm still getting the error. 我尝试使用此行使id字段自动递增,但仍然出现错误。

ALTER TABLE auth_user MODIFY id INT(12) NOT NULL AUTO_INCREMENT;

Thanks for the help. 谢谢您的帮助。

Edit: I ended up deleting all of the dables and using manage.py syncdb to recreate them although that isn't really a solution. 编辑:我最终删除了所有的数据,并使用manage.py syncdb来重新创建它们,但这并不是真正的解决方案。

You probably have incorrect table structure. 您的表格结构可能不正确。 Try to: 尝试:

  1. Create test project and setup connection to test blank database. 创建测试项目并建立连接以测试空白数据库。
  2. Then try to do manage.py syncdb on test project. 然后尝试在测试项目上执行manage.py syncdb
  3. Compare table auth_user structure between current and test project. 比较当前项目和测试项目之间的表auth_user结构。 For example compare create table script for both projects. 例如,比较两个项目的create table脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM