zoukankan      html  css  js  c++  java
  • Django Auth组件->扩展用户

    Auth用户

    1.声明用户表

    djangauth/settings.py
    ..............................
    AUTH_USER_MODEL = 'app01.UserInfo'

    2.定义用户表

    app01/models.py

    ..............................

    from django.db import models

    # Create your models here.
    from django.contrib.auth.models import AbstractUser

    class UserInfo(AbstractUser):
    """
    用户信息表
    """
    nid = models.AutoField(primary_key=True)
    phone = models.CharField(max_length=11, null=True, unique=True)

    def __str__(self):
    return self.username

    3.数据库迁移

     python manage.py makemigrations

       python manage.py migrate

    4.查看生成用户表

    -- auto-generated definition
    create table app01_userinfo
    (
    password varchar(128) not null,
    last_login datetime(6) null,
    is_superuser tinyint(1) not null,
    username varchar(150) not null,
    first_name varchar(30) not null,
    last_name varchar(150) not null,
    email varchar(254) not null,
    is_staff tinyint(1) not null,
    is_active tinyint(1) not null,
    date_joined datetime(6) not null,
    nid int auto_increment
    primary key,
    phone varchar(11) null,
    constraint phone
    unique (phone),
    constraint username
    unique (username)
    );

  • 相关阅读:
    ECMAScript 6 字符串的扩展
    iOS蓝牙开发
    PhotoKit type类型
    HealthKit详解
    苹果证书签名机制
    小程序事件传递
    小程序跳转界面传可变参数
    小程序获取openId
    小程序发起post请求回调成功没有数据
    主干发布和分支发布
  • 原文地址:https://www.cnblogs.com/stonelee2005/p/12101662.html
Copyright © 2011-2022 走看看