G
G
GDApsy2015-10-17 19:48:27
Django
GDApsy, 2015-10-17 19:48:27

How to solve the problem of serializing a custom user model?

In my application, I wrote the user model code, which can be viewed at pythonfiddle.com . Application components used:

  • Django 1.8
  • Django REST framework 3.2.4
  • Django-allauth 0.23.0
  • Django-rest-auth 0.5.

When accessing the registration url, I get the following error:
ValueError at /rest-auth/registration/
Cannot use ModelSerializer with Abstract Models.
. Native serializers for the user model were not defined. Settings related to in-app authentication:
AUTH_USER_MODEL='authservice.MyUser'
ACCOUNT_USER_MODEL_USERNAME_FIELD='email'
ACCOUNT_AUTHENTICATION_METHOD='email'
ACCOUNT_EMAIL_VERIFICATION='mandatory'
ACCOUNT_EMAIL_REQUIRED=True    
ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS=2

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GDApsy, 2015-10-18
@GDApsy

The problem was solved by a more careful study of the values ​​of local variables, which were fixed by the debugger. The problems turned out to be in connecting the authtoken to the application.

S
sim3x, 2015-10-17
@sim3x

to start, do this
and move Meta to the end, behind the methods

class Meta:
        verbose_name = _('user')
        verbose_name_plural = _('users')
        # abstract = False

It looks like magic is powerless here and you need to write the serializer yourself
www.django-rest-framework.org/api-guide/serializer...
stackoverflow.com/questions/25576140/django-rest-f...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question