标签:code ons ida pack upper and ack 数据库 django
由于项目需要扩展django默认新的auth.User系统(添加两个字段:头像、简介等字段),因此就重写了django的默认User类,重写后使用createsupperuser死活创建不了supperuser,提示以下错误:
E:\Work\django\myblog>manage.py createsuperuser --username=joe --email=joe@examp le.com E:\Work\django\myblog>python manage.py createsuperuser --username=joe --email=jo e@example.com Password: Password (again): Traceback (most recent call last): File "manage.py", line 25, in <module> execute_from_command_line(sys.argv) File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line364, in execute_from_command_line utility.execute() File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line356, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Python27\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv self.execute(*args, **cmd_options) File "C:\Python27\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 63, in execute return super(Command, self).execute(*args, **options) File "C:\Python27\lib\site-packages\django\core\management\base.py", line 330, in execute output = self.handle(*args, **options) File "C:\Python27\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 164, in handle validate_password(password2, self.UserModel(**fake_user_data)) File "C:\Python27\lib\site-packages\django\contrib\auth\password_validation.py ", line 49, in validate_password password_validators = get_default_password_validators() File "C:\Python27\lib\site-packages\django\utils\lru_cache.py", line 100, in wrapper result = user_function(*args, **kwds) File "C:\Python27\lib\site-packages\django\contrib\auth\password_validation.py", line 24, in get_default_password_validators return get_password_validators(settings.AUTH_PASSWORD_VALIDATORS) File "C:\Python27\lib\site-packages\django\contrib\auth\password_validation.py", line 34, in get_password_validators raise ImproperlyConfigured(msg % validator[‘NAME‘]) django.core.exceptions.ImproperlyConfigured: The module in NAME could not be imported: django.contrib.vmaig_auth.password_validation.UserAttributeSimilarityValidator. Check your AUTH_PASSWORD_VALIDATORS setting. E:\Work\django\myblog>
>>> from vmaig_auth.models import VmaigUser >>> user=VmaigUser.objects.create_superuser(‘admin‘,‘emailname@demon.com‘,‘new.1234‘)
注意:
1)上边我导入的VmaigUser是我系统覆盖django系统User的用户类,因此我使用该类来直接向数据库中插入记录。
2)需要注意:我这里是使用该方案执行时也出现了错误,尽管出现错误,但是去数据一查询发现确实插入用户数据成功了,而且该用户是可以直接登录django后台。
Django(博客系统):重写了auth.User后使用createsupperuser出错解决办法
标签:code ons ida pack upper and ack 数据库 django
原文地址:http://www.cnblogs.com/yy3b2007com/p/7599820.html