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.lang.NoClassDefFoundError: com/sun/image/codec/jpeg/JPEGCodec

    java.lang.NoClassDefFoundError: com/sun/image/codec/jpeg/JPEGCodec 这个类在 rt.jar 里面 本地开发,jre里有这个包,所以不会 ...

  2. HTTP 错误 405.0 - Method Not Allowed 无法显示您正在查找的页面,因为使用了无效方法(HTTP 谓词)。

    x 前言:报错信息 HTTP 错误 405.0 - Method Not Allowed 无法显示您正在查找的页面,因为使用了无效方法(HTTP 谓词). 发送至 Web 服务器的请求使用了为处理该请 ...

  3. 2018-2019-2 20175320实验二《Java面向对象程序设计》实验报告

    2018-2019-2 20175320实验二<Java面向对象程序设计>实验报告 一.实验步骤及内容 (一)了解使用JUint,并对示例代码MyUtil进行测试 1.先在IDEA中安装J ...

  4. 初步学习python

    自计算机诞生以来,也伴随着计算机语言的诞生,现在,全世界的编程语言有600多种,但流行的编程语言也就20多种. Java和C一直占据着前两名.但是近年来伴随着人工智能的发展,Python发展迅猛,以其 ...

  5. Mac上配置GTK环境

    Mac上配置GTK环境 安装command line工具, 如果安装了Xcode, 就直接跳过该步骤 安装Homebrew 使用brew install pkg-config 使用brew insta ...

  6. linux 环境变量函数getenv()和putenv()的使用

    环境变量相关函数: getenv()和putenv() 代码示例[Linux程序设计(4th)_4.2小节配套代码]: 程序功能:编写一个程序来打印所选的任意环境变量的值:如果给程序传递第二个参数,还 ...

  7. 第 1 章 JS变量、作用域

    目录 一. 判断变量类型 二.作用域 和 上下文 1. 作用链 2. 上下文(this) 二.JS的解析机制 1. 预解析 三.垃圾收集 内存管理销毁 @(es5) 基本类型 引用类型 一. 判断变量 ...

  8. 汇编-10.0-CALL和RET指令

    call和ret指令都是转移指令,他们都是修改IP,或同时修改CS和IP.它们常被共同用来实现子程序设计. 1.ret和retf ret指令用栈中的数据,修改IP的内容,从而实现近转移: retf指令 ...

  9. pdf下载速度

  10. ESP8266开发笔记

    自1999年MIT的Kevin Ash-ton教授首次提出物联网(IoT)的概念至今已经有20年了.放眼现在国内外的物联网市场,真可谓是百家争鸣,方兴未艾,无数家软硬件公司在这里舞浪弄潮,逐鹿其中,上 ...