0

From what I have read, the create_user (and create_superuser) method receives required parameters only. I;m trying to create an user whit required and non-required parameters, by adding another argument to the create_user function I've got errors.
I did override the User model from auth module, so MyUser is an AbstractBaseUser and its manager is a BaseUserManager.
I have a view where a pretend to create the user with required and non-required fields, should I override init?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
  • cf Django docs : "The extra_fields keyword arguments are passed through to the User’s __init__ method to allow setting arbitrary fields on a custom User model" => it should work, what is the error ? – Raphaël Braud Mar 27 '15 at 14:33

1 Answers1

1

The create_user function is just a shortcut. You should instantiate a user with user = MyUser(field1=arg1, field2=arg2), remember to use the set_password function for the password, and call user.save().

There is a generic create method as well that accepts all fields available on your user model, but I don't know if it handles passwords correctly.

knbk
  • 52,111
  • 9
  • 124
  • 122