add simple user admin and hash password

This commit is contained in:
Timur
2025-03-01 17:40:08 +03:00
parent 9a5a924333
commit 656735649d
6 changed files with 25 additions and 2 deletions
+8 -1
View File
@@ -1,4 +1,5 @@
from django.db import models
from django.contrib.auth.hashers import check_password, make_password
from apps.core.models import BaseModel
@@ -11,7 +12,13 @@ class UserRole(models.Choices):
class User(BaseModel):
email = models.EmailField(unique=True, verbose_name="почта")
username = models.SlugField(unique=True, verbose_name="юзернейм")
password = models.TextField(verbose_name="пароль")
password = models.TextField(verbose_name="пароль", editable=False)
def make_password(self):
return make_password(self.password)
def check_password(self, password):
return check_password(self.password, password)
status = models.CharField(
max_length=10, choices=UserRole, default="student"