Create a serializer for custom user model in django-rest-auth?

878 views Asked by At

I've installed django-rest-framework. Also i've installed django allauth.
Now i want to use django-rest-auth based on previous two, for serializing data
and sending it in json format as answer on my submit form method (for registration/login etc).
I look up into documentation is provided for django-rest-auth but it feels for me strange, as i inherit(and must do so) from the AbstractBaseUser and not simply do OneToOneField on existing User model. At the moment the model i assign to the AUTH_USER_MODEL in my settings.py is:

class Account(AbstractBaseUser, PermissionsMixin):
    email = models.EmailField(unique=True, db_index=True, verbose_name='Account Email')

    is_admin = models.BooleanField(default=False)
    is_staff = models.BooleanField(default=False)
    is_employer = models.BooleanField(default=False)
    is_active = models.BooleanField(default=True)

    created_at = models.DateTimeField(auto_now_add=True)

    objects = AccountManager()

    USERNAME_FIELD = 'email'

The question is: how can i use serializing in rest-auth the same way, but using my model instead of provided UserProfile model example ?

1

There are 1 answers

0
Maz On

Yes you may inherit it, and use serializers the way you are saying. It should work. Please state where the error arises when you are using serializers for this.