>  AUTH_USER_MODEL = 'users.User

Yep, I have that in settings.py

In serializers.py if I change EmailField to CharField, it does serialize. 
However, then it’s not really checking if it’s a email. And EmailField should 
work.
>>>> class User(AbstractBaseUser, PermissionsMixin):
>>>>     email = models.CharField(max_length=256, unique=True)
Thank you DjangoUsers

> On Mar 27, 2020, at 4:49 AM, Motaz Hejaze <trapper...@gmail.com> wrote:
> 
> 
> I think django doesnt recognize your custom user model ..
> 
> Did you your app to installed app and put AUTH_USER_MODEL = 'myapp.MyUser' 
> in settings.py ?
> 
>> On Fri, 27 Mar 2020, 3:33 am devyen, <devyen...@gmail.com> wrote:
>> Hi 
>> 
>> Do know how to whitelist an email domain name? It seems odd that I would 
>> have to go though an white list all of the main email domains (gmail, 
>> protonmail, live, yahoo etc.)
>> 
>> Ive been unable to figure it out on my own
>>  
>> Thanks,
>> 
>> 
>> 
>>> On Sat, Mar 21, 2020 at 4:45 AM Integr@te System <datacentral...@gmail.com> 
>>> wrote:
>>> Hi Freind,
>>> 
>>> Try to set whitelist for your specific domain testing or refer doc for your 
>>> case. 
>>> 
>>> 
>>>> On Sat, Mar 21, 2020, 03:47 devyen <devyen...@gmail.com> wrote:
>>>> Hi,
>>>> 
>>>> I am tying to use the EmailField in my AbstractBaseUser Class see below. 
>>>> However the serializer does not recognize any emails as valid (I tested 
>>>> with this one, which is clearly valid) 
>>>> 
>>>> Can you help me?
>>>> 
>>>> Thank you so much!
>>>> 
>>>> 
>>>> models.py
>>>> class User(AbstractBaseUser, PermissionsMixin):
>>>>     email = models.EmailField(max_length=256, unique=True)
>>>>     first_name = models.TextField(verbose_name="First Name", blank=True)
>>>>     last_name = models.TextField(verbose_name="Last Name", blank=True)
>>>>     user_id = models.TextField(unique=True)
>>>>     data = JSONField(default=default_data, name="device_data")
>>>>     is_staff = models.BooleanField(default=False)
>>>>     is_active = models.BooleanField(default=True)
>>>>     date_joined = models.DateTimeField(default=timezone.now)
>>>> 
>>>>     objects = UserManager()
>>>> 
>>>>     USERNAME_FIELD = 'email'
>>>> 
>>>>     def __str__(self):
>>>>         return self.email
>>>> 
>>>>     def get_first_name(self):
>>>>         return self.first_name
>>>> 
>>>>     def get_last_name(self):
>>>>         return self.last_name
>>>> 
>>>>     def get_email(self):
>>>>         return self.email
>>>> 
>>>>     def __unicode__(self):
>>>>         return self.email, self.user_id
>>>> 
>>>>     def get_user_id(self):
>>>>         return self.user_id
>>>> serializers.py
>>>> 
>>>> from rest_framework import serializers
>>>> from .models import User
>>>> 
>>>> 
>>>> class UserSerializer(serializers.ModelSerializer):
>>>>     class Meta:
>>>>         model = User
>>>>         fields = ['email', 'password']
>>>> 
>>>> part of views.py
>>>> 
>>>> class UserRegistration(APIView):
>>>>     def post(self, request):
>>>>         serializer = UserSerializer(data=request.data)
>>>>         if serializer.is_valid():
>>>>             print('valid')
>>>>             user_object = []
>>>>             email = serializer.validated_data['email']
>>>>             password = serializer.validated_data['password']
>>>>             if "first_name" in serializer.validated_data:
>>>>                 first_name = serializer.validated_data['first_name']
>>>>                 user_object.append(first_name)
>>>>             else:
>>>>                 pass
>>>>             if "last_name" in serializer.validated_data:
>>>>                 last_name = serializer.validated_data['last_name']
>>>>                 user_object.append(last_name)
>>>>             else:
>>>>                 pass
>>>> 
>>>>             # serializer.save()
>>>>             return Response(user_object, status=status.HTTP_201_CREATED)
>>>>         return Response(serializer.errors, 
>>>> status=status.HTTP_400_BAD_REQUEST)
>>>> 
>>>> I send this:
>>>> http -f POST http://127.0.0.1:8000/reg email='k...@k.com', password='pw'
>>>> 
>>>> 
>>>> to receive this error:
>>>> {
>>>> 
>>>>     "email": [
>>>> 
>>>>         "Enter a valid email address."
>>>> 
>>>>     ]
>>>> 
>>>> }
>>>> 
>>>> -- 
>>>> You received this message because you are subscribed to the Google Groups 
>>>> "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>>> email to django-users+unsubscr...@googlegroups.com.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/django-users/bc92176b-7eb2-4e2a-a8a0-215eef7392c7%40googlegroups.com.
>>> 
>>> -- 
>>> You received this message because you are subscribed to a topic in the 
>>> Google Groups "Django users" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/django-users/NHUy2I3ZVDg/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to 
>>> django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/CAP5HUWrxXTmMovbmz2KCUG6%3DRMy10fNW6A-hkQdkbNWqZxYGNw%40mail.gmail.com.
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CA%2B%3DqY%3DPvkQe%2B6EdeMRZaiJ%3DnYKn%3Dd1b_JivqL4c4%3Dacr28D74Q%40mail.gmail.com.
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Django users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/django-users/NHUy2I3ZVDg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAHV4E-d4s0OnS9%2Bd7%3D4Be7NG4Xa5v%2BNcx5r7%3DpiwV3KjcOJQGw%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/51C89967-0014-40E0-9023-A67E0390518F%40gmail.com.

Reply via email to