社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

Arun

Arun 最近回复了
2 年前
回复了 Arun 创建的主题 » python列表中的count函数

我认为出现错误的原因是,您试图将字符串和整数连接起来,这在python中是不可能的,不像javascript。因此,尝试使用str关键字将整数转换为字符串,然后连接。

在models.py文件中添加以下函数。然后运行makemigrations和migrate。在Django1.7上测试

def set_email_as_unique():
    """
    Sets the email field as unique=True in auth.User Model
    """
    email_field = dict([(field.name, field) for field in MyUser._meta.fields])["email"]
    setattr(email_field, '_unique', True)

#this is called here so that attribute can be set at the application load time
set_email_as_unique()