[Python] 'RegisterSerializer' object has no attribute '_has_phone_field'

Discussão em 'Python' iniciado por Stack, Agosto 16, 2025.

  1. Stack

    Stack Membro Participativo

    dj-rest-auth library has been returning this error when I send a request into the /registration endpoint

    from rest_framework import serializers
    from dj_rest_auth.registration.serializers import RegisterSerializer

    class RegSerializer(RegisterSerializer):
    phone = serializers.CharField(required = False)

    def get_cleaned_data(self):
    data= super().get_cleaned_data()
    data['phone']=self.validated_data.get("phone","")
    return data

    Error message:


    AttributeError at /auth/dj-rest-auth/registration/ 'RegisterSerializer' object has no attribute '_has_phone_field'

    Error location:


    C:\...\site-packages\allauth\account\adapter.py, line 338, in save_user

    which points to this..

    def save_user(self, request, user, form, commit=True):
    from .utils import user_email, user_field, user_username

    data = form.cleaned_data
    first_name = data.get("first_name")
    last_name = data.get("last_name")
    email = data.get("email")
    username = data.get("username")
    user_email(user, email)
    user_username(user, username)
    if first_name:
    user_field(user, "first_name", first_name)
    if last_name:
    user_field(user, "last_name", last_name)
    if "password1" in data:
    user.set_password(data["password1"])
    elif "password" in data:
    user.set_password(data["password"])
    else:
    user.set_unusable_password()
    self.populate_username(request, user)
    if commit:
    user.save()
    if form._has_phone_field:
    phone = form.cleaned_data.get("phone")
    if phone:
    self.set_phone(user, phone, False)
    return user



    Tried to extend the RegisterSerializer that exists in the package, still didn't work, I followed the docs thoroughly but the issue persists, I don't see where the problem lies.

    Continue reading...

Compartilhe esta Página