我尝试执行“./manage.py syncdb”,并提示我创建一个超级用户,但它失败了:
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/<USER>/.virtualenvs/<DOMAIN>/src/django-trunk/django/core/management/__init__.py", line 397, in execute_from_command_line
utility.execute()
File "/home/<USER>/.virtualenvs/<DOMAIN>/src/django-trunk/django/core/management/__init__.py", line 390, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/<USER>/.virtualenvs/<DOMAIN>/src/django-trunk/django/core/management/base.py", line 240, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/<USER>/.virtualenvs/<DOMAIN>/src/django-trunk/django/core/management/base.py", line 283, in execute
output = self.handle(*args, **options)
File "/home/<USER>/.virtualenvs/<DOMAIN>/src/django-trunk/django/contrib/auth/management/commands/createsuperuser.py", line 141, in handle
self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
TypeError: create_superuser() takes exactly 4 arguments (3 given)
这是我的用户资料:
from django.db import models
from django.conf import settings
from django.contrib.auth.models import UserManager, AbstractUser
class UserProfile(AbstractUser):
membernumber = models.CharField(max_length=20, blank=True, unique=True)
mobile = models.CharField(max_length=20, blank=True)
updated = models.DateTimeField(blank=True, null=True)
USERNAME_FIELD = 'membernumber'
objects = UserManager()
也许问题是我已经运行了“syncdb”并且在唯一字段上有“blank=True”?