【发布时间】:2014-12-10 23:55:58
【问题描述】:
我无法在 auth_user 表上创建唯一的电子邮件字段
在 Django 1.6 版本上 我将该字符串添加到 huote/settings.py 并且一切正常 User._meta.get_field('email')._unique=True
在 1.7 版本上,我在下面尝试这个示例,因为我有错误 django.core.exceptions.AppRegistryNotReady:模型尚未加载。
但它不起作用
-- huote/apps.py--
from django.apps import AppConfig
from django.contrib.auth.models import User
class YourAppConfig(AppConfig):
name="huote"
def ready(self):
User._meta.get_field('email')._unique=True
-- "huote/__init__.py" --
default_app_config = 'huote.apps.YourAppConfig'
【问题讨论】: