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)
    );

  • 相关阅读:
    zoj 3715 K
    bzoj 2002(弹飞绵羊) 分块
    最大01矩阵(悬线法)
    csu 1809 Parenthesis(线段树)
    csu 1804(有向无环图)
    csu 1803(2016)
    RCC 2017 Qual 1 Mail.Ru, April 2, 2017 Problem C. Magic Artifact
    Unmarshaller解析xml文件
    sax解析xml文件,封装到对象中
    cas环境搭建
  • 原文地址:https://www.cnblogs.com/stonelee2005/p/12101662.html
Copyright © 2011-2022 走看看