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. linux定时备份mysql数据并同步到其他服务器

    (备份还原操作) ###导出数据库 /usr/bin/mysqldump -u root -pwd database > database20180808.sql ###导入数据库 mysql ...

  2. pytorch入门与实践-3 Tensor详解

    1--如第二章所讲,Tensor的本质是矩阵或数据 2--对Tensor的操作分类 |----API分类 |------torch中定义的: t.f(a,b) |------tensor的成员函数: ...

  3. 在C++中,子类重载一个操作符时,如何调用父类被重载的操作符函数

    使用static_cast运算符将子类转换为父类即可 #include <iostream> using namespace std; class Base { public: Base( ...

  4. 基于STM32的USB枚举过程学习笔记(转)

    之前使用ST官方的库以及网络的资料,完成了使用USB HID类进行STM32和PC机的通讯.由于其他原因并没有深入的分析,虽然实现了功能,但是关于USB设备的枚举,以及具体的通讯方式都没有清晰的概念, ...

  5. direction: rtl;

    这个属性,有点无语,费了点时间. <style type="text/css"> .hao {direction: rtl;}</style> <se ...

  6. JS promise

    1.Promise是什么? Promise是抽象异步处理对象以及对其进行各种操作的组件. 2.实例化 使用new来调用Promise的构造器来进行实例化 var promise = new Promi ...

  7. 安装Nginx到linux服务器(Ubuntu)详解

    先去下载一个nginx放到服务器. 然后解压(可参考前面安装tomcat)编译(./configure --prefix=/usr/local/nginx/server/ && mak ...

  8. 【转】tars源码漫谈第1篇------tc_loki.h (牛逼哄哄的loki库)

    loki库是C++模板大牛Andrei写的, 里面大量运用模板的特性, 而tc_loki.h借用了loki库的部分代码, 形成了一个基本的文件tc_loki.h, 来看看: #ifndef __TC_ ...

  9. Windows命令行设置dns

    管理员运行cmd 1.dns配置成192.168.1.200 netsh interface ip set dns name="以太网" source=static addr=19 ...

  10. btcpool之总架构

    一.架构图 二.模块划分 整个btcpool分成GbtMaker.BlockMaker.JobMaker.StratumServer.PoolWatcher.statshttpd.sharelogge ...