I would like to set the CustomUser username using the input email address, but where to make the user assignment? At the same time, he receives the file.
Models.py
class CustomUser(AbstractUser): avatar = models.ImageField(max_length=None, upload_to='avatar', blank=True)
Serializers.py
class CustomUserSerializer(serializers.ModelSerializer): class Meta: model = CustomUser fields = ('id', 'first_name', 'last_name', 'email', 'password', 'avatar', 'groups')
Views.py
class CustomUserViewSet(viewsets.ModelViewSet): queryset = CustomUser.objects.all() serializer_class = CustomUserSerializer
thank you in advance.
source share