我有一个A models.py
models.py
class User(AbstractUser, BaseModel):
full_name = models.CharField(max_length=64)
addresss=models.CharField(max_length=40)
phoneno=models.IntegerField(null=True, blank=True)
email=models.EmailField()
password=models.CharField(max_length=40)
re_password=models.CharField(max_length=40)
gender=models.IntegerField(choices=gender_choice,default='0')
serializers.py
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ('full_name','id','addresss','phoneno','email','gender')
views.py
class StudentViewset(viewsets.ModelViewSet):
queryset = Student.objects.all()
serializer_class = StudentSerializer
http_methods = ['get', 'post','put','delete']
def create(self, request):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
row = serializer.data
user=User.objects.get_or_create(
defaults={'full_name':row['user']['full_name'],'addresss':row['addresss'],
'phoneno':row['phoneno'],'password':row['password'] ,'re_password':row[['re_password'],
'gender':row['gender'] ,'username':username})
我的问题:
注册学生后,我想生成一封类似于他/她的电子邮件(地址@ gmail.com)。
我该怎么做?