From 80db592723cb896e7e080791beafde87f883033c Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Mon, 3 Mar 2025 10:23:10 +0800 Subject: [PATCH] update --- .gitignore | 1 + account/migrations/0002_user_role.py | 18 ++++++++++++++++++ account/models.py | 14 ++++++++++++-- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 account/migrations/0002_user_role.py diff --git a/.gitignore b/.gitignore index 64ab79e..7c33b83 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ venv +.venv **/__pycache__ db.sqlite3 .env \ No newline at end of file diff --git a/account/migrations/0002_user_role.py b/account/migrations/0002_user_role.py new file mode 100644 index 0000000..43eec53 --- /dev/null +++ b/account/migrations/0002_user_role.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.6 on 2025-03-03 02:15 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('account', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='user', + name='role', + field=models.CharField(choices=[('super', '超级管理员'), ('admin', '管理员'), ('normal', '普通')], default='normal', max_length=20), + ), + ] diff --git a/account/models.py b/account/models.py index 239315f..8aef0ed 100644 --- a/account/models.py +++ b/account/models.py @@ -1,7 +1,17 @@ from django.db import models -# Create your models here. from django.contrib.auth.models import AbstractUser + +class RoleChoices(models.TextChoices): + SUPER = "sup er", "超级管理员" + ADMIN = "admin", "管理员" + NORMAL = "normal", "普通" + + class User(AbstractUser): - pass + role = models.CharField( + max_length=20, + choices=RoleChoices.choices, + default=RoleChoices.NORMAL, + )