view中导入:from django.contrib.auth.models import AbstractBaseUser

settings.py中设置了:AUTH_USER_MODEL='app名.model自定义类'

解决方法:在自定义类中加:

  identifier = models.CharField(max_length=40, unique=True)
  USERNAME_FIELD = 'identifier'

view中导入from django.contrib.auth.models import AbstractUser 则不会出现该问题

重写用户模型时报错AttributeError: type object ‘自定义类’ has no attribute ‘USERNAME_FIELD’的更多相关文章

  1. ddt运行测试方法时报错AttributeError: type object 'TestHttpRq' has no attribute 'test_http_rq_login'

    import unittest import ddt #装饰器 from ddt import ddt,data,unpack #导入ddt中的各个模块 from homework.unittest_ ...

  2. Python - celery 相关报错 - AttributeError: type object '_multiprocessing.win32' has no attribute 'WAIT_OBJECT_0'

    报错场景 执行   celery worker -A tasks -l INFO  打开 worker 的时候报错无法进行 报错解决 Celery 的版本过高, 进行降级处理即可 pip instal ...

  3. Django重写用户模型报错has no attribute 'USERNAME_FIELD'

    目录 Django重写用户模型报错has no attribute 'USERNAME_FIELD' 在重写用户模型时报错:AttributeError: type object 'UserProfi ...

  4. facenet pyhton3.5 训练 train_softmax.py 时报错AttributeError: 'dict' object has no attribute 'iteritems'

    报错原因:在进行facenet进行train_softmax.py训练时,在一轮训练结束进行验证时,报错AttributeError: 'dict' object has no attribute ' ...

  5. zc.buildout构建项目时报错‘AttributeError: '_NamespacePath' object has no attribute 'sort'’

    在使用zc.buildout构建项目时如果碰到‘AttributeError: '_NamespacePath' object has no attribute 'sort'’报错: An inter ...

  6. ddt运行报错AttributeError: type object 'TestLogin' has no attribute 'test_login'

    源代码: #!usr/bin/python3 # -*- coding:utf-8 -*- # @Time: 2018/12/17 下午2:07 # @File: do_excel.py # @Sof ...

  7. AttributeError: type object '_io.StringIO' has no attribute 'StringIO'

    python2导入StringIO模块,直接: from StringIO import StringIO 对于python3,StringIO和cStringIO模块已经没了,如果要使用的话,需要导 ...

  8. PHP json_decode object时报错Cannot use object of type stdClass as array

    PHP json_decode object时报错Cannot use object of type stdClass as array php再调用json_decode从字符串对象生成json对象 ...

  9. Django 重写用户模型

    AUTH_USER_MODEL = 'myapp.MyUser' django——重写用户模型 Django内建的User模型可能不适合某些类型的项目.例如,在某些网站上使用邮件地址而不是用户名作为身 ...

随机推荐

  1. Java自学笔记

    1.标识符:字母,数字,下划线,美元符组成,不可以已数字开头,并且严格区分大小写 2.变量 有三个元素描述变量,变量类型,变量名,变量值 如何命名变量:首字母为 字母:下划线:“$“符号,其余部分为 ...

  2. 面向面试编程代码片段之GC

    x 代码 using System; using System.Threading; public static class Program{ public static void Main(){ T ...

  3. box-sizing (摘录)

    //http://www.jianshu.com/p/e2eb0d8c9de6 box-sizing其它的值 content-box 描述:在宽度和高度之外绘制元素的内边距和边框. border-bo ...

  4. js canvas获取图片base64 dataUrl

    function getImgBase64(path, callback) { var img = new Image(); img.src = path; //图片加载完成后触发 img.onloa ...

  5. $_SERVER服务器端

    url = 'http://www.5idev.com/php/index.php/test/foo?username=hbolive' php 获取$_SERVER信息 $_SERVER['PHP_ ...

  6. 5. Scala函数式编程的基础

    5.1 函数式编程内容及介绍顺序说明 5.1.1 函数式编程内容 -函数式编程基础 函数定义/声明 函数运行机制 递归(难点,[最短路径,邮差问题,迷宫问题,回溯]) 过程 惰性函数和异常 -函数式编 ...

  7. iostat查看io情况

      查看TPS和吞吐量信息[root@controller ~]#iostat -d -k 1 10Device:         tps    kB_read/s    kB_wrtn/s    k ...

  8. WebSocket(一)-RFC6455

    1.官方在线 本地下载 参考翻译:gitbook

  9. 001-JUnit之断言assert

    一.简介以及pom JUnit4.4引入了Hamcrest框架,Hamcest提供了一套匹配符Matcher,这些匹配符更接近自然语言,可读性高,更加灵活: 使用全新的断言语法:assertThat, ...

  10. Data type

    先放官方文档: https://dev.mysql.com/doc/refman/5.5/en/data-types.html MySQL支持多种类型的SQL数据类型:数字类型,日期和时间类型,字符串 ...