我有一个使用django_mongodb_engine
and的应用程序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_FIELD
,not unique
但是当我尝试使用 时python manage.py runserver
,在验证模型时它给了我以下错误:
CommandError: The USERNAME_FIELD must be unique. Add unique=True to the field parameters.
当我在 Heroku 上部署它时,它工作正常。