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. PAT甲级1103 Integer Factorization【dfs】【剪枝】

    题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805364711604224 题意: 给定一个数n,要求从1~n中找 ...

  2. POJ 2533 - Longest Ordered Subsequence - [最长递增子序列长度][LIS问题]

    题目链接:http://poj.org/problem?id=2533 Time Limit: 2000MS Memory Limit: 65536K Description A numeric se ...

  3. ReactJS antd 环境中项目上传图片后压缩(lrz的使用)

    lrz说明 ( github地址 :https://github.com/think2011/localResizeIMG ) 用于:在客户端压缩好要上传的图片可以节省带宽更快的发送给后端,特别适合在 ...

  4. Spring Boot Thmeleaf的语法 day04

    一.Thmeleaf语法的使用 html格式的页面放在classpath:/templates/就会自动渲染. 1.在pom.xml导入 <dependency> <groupId& ...

  5. app启动过程

    调用main函数之前: App开始启动后,系统首先加载可执行文件(自身App的所有.o文件的集合),然后加载动态链接库dyld.交由 ImageLoader 读取 image,其中包含了我们的类.方法 ...

  6. LINQ交集/并集/差集/去重

    using System.Linq; List<string> ListA = new List<string>(); List<string> ListB = n ...

  7. StringBuufer与StringBulder线程的区别

    StringBulder的append方法 不是synchronized修饰的   线程不安全     效率相对很快StringBuufer的append方法  是 synchronized修饰的  ...

  8. element-ui+vue-treeselect校验

    element-ui+vue-treeselect下拉框的校验 问题陈述: 在element-ui中有自带的表单验证,但是使用的vue-treeselect无法验证 vue-treeselect DE ...

  9. 简介一下 i++和++i&&i=i+i,i+=1;的区别

    首先: int i=2; i++=2; ++i=3; 前者先显示当前的值,而后者则是先自增在显示值: second i=i+1和i+=1; 输出结果虽然一样,但是 1.byte i=2; i+=2; ...

  10. Mac OS X 下安装使用 Docker (2017年7月)

    两年前的一篇 Mac OS X 下安装使用 Docker 安装时还是用的 boot2docker, 如今进化到了在 Mac OS X 下用 Docker Toolbox, 而且命令也由 boot2do ...