python管理.py自定义用户mod的runserver Vs foreman start

2024-05-23 17:50:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个应用程序使用django_mongodb_enginemongolab(没有python)管理.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上部署它时,它工作得很好。你知道吗


Tags: py模型zonefieldmodelsusernameforemanregistration