Commit f0b0e41d authored by ibuler's avatar ibuler

Update user edit

parent 308aa2ec
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
from django.forms import ModelForm from django.forms import ModelForm
from django import forms from django import forms
from .models import User, UserGroup, Role from .models import User, UserGroup
class UserAddForm(ModelForm): class UserAddForm(ModelForm):
...@@ -41,13 +41,19 @@ class UserUpdateForm(ModelForm): ...@@ -41,13 +41,19 @@ class UserUpdateForm(ModelForm):
'groups': '* required' 'groups': '* required'
} }
widgets = {
'groups': forms.SelectMultiple(attrs={'class': 'chosen-select', 'data-placeholder': '请选择用户组'}),
}
class UserGroupForm(ModelForm): class UserGroupForm(ModelForm):
class Meta: class Meta:
model = UserGroup model = UserGroup
fields = [ fields = [
'name', 'comment', 'name', 'comment',
] ]
help_texts = { help_texts = {
'name': '* required' 'name': '* required'
} }
...@@ -86,9 +86,9 @@ def date_expired_default(): ...@@ -86,9 +86,9 @@ def date_expired_default():
class User(AbstractUser): class User(AbstractUser):
username = models.CharField(max_length=20, unique=True, verbose_name='用户名') username = models.CharField(max_length=20, unique=True, verbose_name='用户名')
name = models.CharField(max_length=20, verbose_name='姓名', help_text='* required') name = models.CharField(max_length=20, verbose_name='姓名')
email = models.EmailField(max_length=30, unique=True, verbose_name='邮件', help_text='* required') email = models.EmailField(max_length=30, unique=True, verbose_name='邮件')
groups = models.ManyToManyField(UserGroup, verbose_name='用户组', help_text='* required') groups = models.ManyToManyField(UserGroup, verbose_name='用户组')
avatar = models.ImageField(upload_to="avatar", verbose_name='头像') avatar = models.ImageField(upload_to="avatar", verbose_name='头像')
wechat = models.CharField(max_length=30, blank=True, verbose_name='微信') wechat = models.CharField(max_length=30, blank=True, verbose_name='微信')
phone = models.CharField(max_length=20, blank=True, verbose_name='手机号') phone = models.CharField(max_length=20, blank=True, verbose_name='手机号')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment