0

我有一个使用django_mongodb_engineand的应用程序mongolab(不需要 python manage.py syncdb)。我也foreman用作我的本地服务器。

档案:

web: gunicorn <appname>.wsgi

我有以下自定义用户模型Registration

class Registration(AbstractBaseUser):
    username = models.CharField(max_length=50)
    email = models.CharField(max_length=50)
    created_at = models.DateTimeField()
    zone = models.IntegerField()

    objects = RegistrationManager()
    USERNAME_FIELD = 'username'
    REQUIRED_FIELDS = ['created_at', 'zone']

现在,当我输入 时foreman start,它完全按照我想要的方式工作。那是USERNAME_FIELDnot unique但是当我尝试使用 时python manage.py runserver,在验证模型时它给了我以下错误:

CommandError: The USERNAME_FIELD must be unique. Add unique=True to the field parameters.

当我在 Heroku 上部署它时,它工作正常。

4

1 回答 1

0

看看django 文档

USERNAME_FIELD必须定义为 Unique=True

于 2015-02-01T03:16:37.003 回答