Skip to content
Advertisement

serializer not being called AttributeError: ‘str’ object has no attribute ‘_meta’

I modified the Auth User by using AbstractUser Class. Registered it in settings. Everything else is working I can create an instance using the User Model BUT

The Problem comes during the serialization. My serializer doesn’t throw any error, but any time I try and use the serializer.data I get AttributeError: ‘str’ object has no attribute ‘_meta’.

User Model

JavaScript

Custom Manager

JavaScript

User Serializer

JavaScript

View

JavaScript

I’ve stuck with the code for the last 7-8 hours. Even tried specifying the fields but I haven’t been able to figure out why this is happening.

Advertisement

Answer

You should work with the get_user_model() function [Django-doc] to obtain a reference to the user model, the AUTH_USER_MODEL setting [Django-doc] is only a string to the name of that model:

JavaScript
Advertisement