You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
438 B
15 lines
438 B
|
10 months ago
|
from django.db.models.signals import post_save
|
||
|
|
from django.dispatch import receiver
|
||
|
|
from django.contrib.auth import get_user_model
|
||
|
|
|
||
|
|
User = get_user_model()
|
||
|
|
|
||
|
|
|
||
|
|
@receiver(post_save, sender=User)
|
||
|
|
# 注册一个信号,在创建用户时自动加密密码
|
||
|
|
def create_user(sender, instance=None, created=False, **kwargs):
|
||
|
|
if created:
|
||
|
|
password = instance.password
|
||
|
|
# instance.set_password(password)
|
||
|
|
# instance.save()
|