4

I am using djoser with django rest framework, and I want to remove the username field from the create user form:

settings.py:

'SERIALIZERS': {
    'user_create': 'user.serializers.UserRegistrationSerializer',
},

serializers.py:

class UserRegistrationSerializer(BaseUserRegistrationSerializer):
    class Meta(BaseUserRegistrationSerializer.Meta):
        fields = ('email', 'password')

I received the following error. How do you fix this?

TypeError at /auth/users/create
create_user() missing 1 required positional argument: 'username'
Lypyrhythm
  • 324
  • 2
  • 13
Hassam Ali
  • 171
  • 2
  • 12
  • 1
    Salaam @Hassam Ali did you figure this out? I am trying solve the same issue atm. – Mr B May 03 '20 at 19:16

1 Answers1

0

According to djoser documentation User Create

Use this endpoint to register new user. Your user model manager should implement create_user method and have USERNAME_FIELD and REQUIRED_FIELDS fields

You have to customize your user model not the serializers.

I'm fact I don't recognize the serializers you used as belonging to djoser.

Additional questions:

  • Do you want to replace username filed with email?
Kamil Niski
  • 4,580
  • 1
  • 11
  • 24