6👍
✅
Your create
method is not returning an object instance. You should return the result of the User.objects.create(...)
call.
def create(self, validated_data):
profile_data = validated_data.pop('profile')
user = User.objects.create_user(**validated_data)
UserProfile.objects.create(
user = user,
first_name = profile_data['first_name'],
last_name= profile_data['last_name'],
)
return user
0👍
you did not return the user in your create method.
class UserManager(BaseUserManager):
def create_user(self, username, email, password=None):
if username is None:
raise TypeError('User should have a username')
if email is None:
raise TypeError('User should have an email')
user = self.model(username=username, email=self.normalize_email(email))
user.set_password(password)
user.save()
return user
- [Django]-URL issue when using lighttpd, django and fastcgi
- [Django]-Pass variable from middleware to templates
0👍
I had the same error too.
In your serializer.py
:
at the top add:
from django.contrib.auth import get_user_model
User = get_user_model()
This worked for me as I was using a custom user.
- [Django]-Can't get nginx to serve collected static files
- [Django]-Django post_save and south migrations
Source:stackexchange.com