老师我这是什么情况?为什么这两个字段在最前面?
from django.db import models class CommonModel(models.Model): """ 自定义模型的基类 """ created_at = models.DateTimeField('注册时间', auto_now_add=True) updated_at = models.DateTimeField('更新时间', auto_now=True) class Meta: # 抽象类,这个类不会生成对应的数据库表 abstract = True class User(CommonModel): """ 用户基本信息 """ USER_STATUS = ( (1, '正常'), (0, '删除') ) username = models.CharField('用户名', max_length=128, unique=True) password = models.CharField('密码', max_length=256) nickname = models.CharField('用户昵称', max_length=256, null=True, blank=True) avatar = models.ImageField('用户头像', upload_to='avatar', null=True, blank=True) status = models.SmallIntegerField('用户状态', default=1, choices=USER_STATUS) is_super = models.BooleanField('是否为超级用户', default=False) class Meta: db_table = 'account_user' class UserProfile(CommonModel): """ 用户详细信息 """ SEX_CHOICES = ( (0, '未知'), (1, '男'), (2, '女') ) user = models.OneToOneField(User, verbose_name='关联用户', related_name='profile', on_delete=models.CASCADE) username = models.CharField('用户名', max_length=128, unique=True) real_name = models.CharField('真实名', max_length=128, unique=True, null=True, blank=True) sex = models.SmallIntegerField('用户性别', default=0, choices=SEX_CHOICES) maxim = models.CharField('用户格言', max_length=128, unique=True, null=True, blank=True) address = models.CharField('用户地址', max_length=128, unique=True, null=True, blank=True) class Meta: db_table = 'account_user_profile' class LoginHistory(models.Model): """ 用户的登录历史 """ user = models.ForeignKey(User, related_name='login_history_list', on_delete=models.CASCADE, verbose_name='关联的用户') username = models.CharField('用户名', max_length=128) login_type = models.CharField('账号平台', max_length=128) ip = models.CharField('IP地址', max_length=32, default='') ua = models.CharField('登录的来源', max_length=128, default='') created_at = models.DateTimeField('登录时间', auto_now_add=True) class Meta: db_table = 'account_login_history' ordering = ['-created_at']
4
收起
正在回答 回答被采纳积分+1
1回答
Python全能工程师
- 参与学习 人
- 提交作业 16247 份
- 解答问题 4470 个
全新版本覆盖5大热门就业方向:Web全栈、爬虫、数据分析、软件测试、人工智能,零基础进击Python全能型工程师,从大厂挑人到我挑大厂,诱人薪资在前方!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星