Files
jiangmingzhao-daily-report/backend/accounts/models.py
jiangmingzhao 9b9ee273fc 初始提交:企业级日报系统完整代码
功能特性:
-  JWT用户认证系统
-  日报CRUD管理
-  三级权限控制
-  多维度搜索过滤
-  统计分析功能
-  评论互动系统
-  响应式Cool Admin界面
-  暗色主题支持

 技术栈:
- 后端:Django 4.2.7 + DRF + SimpleJWT
- 前端:Vue 3 + Element Plus + Pinia
- 数据库:SQLite/PostgreSQL
- 部署:Docker + Nginx

 包含内容:
- 完整的后端API代码
- 现代化前端界面
- 数据库迁移文件
- 部署脚本和文档
- 演示页面和测试工具
2025-09-13 14:35:15 +08:00

40 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from django.contrib.auth.models import AbstractUser
from django.db import models
class User(AbstractUser):
"""扩展用户模型"""
phone = models.CharField('手机号码', max_length=11, blank=True, null=True)
department = models.CharField('部门', max_length=100, blank=True, null=True)
position = models.CharField('职位', max_length=100, blank=True, null=True)
# 暂时移除头像字段避免Pillow依赖
# avatar = models.ImageField('头像', upload_to='avatars/', blank=True, null=True)
created_at = models.DateTimeField('创建时间', auto_now_add=True)
updated_at = models.DateTimeField('更新时间', auto_now=True)
# 解决反向访问器冲突
groups = models.ManyToManyField(
'auth.Group',
verbose_name='groups',
blank=True,
help_text='The groups this user belongs to.',
related_name="custom_user_set",
related_query_name="custom_user",
)
user_permissions = models.ManyToManyField(
'auth.Permission',
verbose_name='user permissions',
blank=True,
help_text='Specific permissions for this user.',
related_name="custom_user_set",
related_query_name="custom_user",
)
class Meta:
verbose_name = '用户'
verbose_name_plural = verbose_name
db_table = 'auth_user_custom'
def __str__(self):
return f'{self.username} - {self.first_name or self.username}'