'CustomUserForm' object has no attribute 'save_m2m' when creating custom user

Viewed 19

I am trying to create a user using the following code:

class CustomUserCreationForm(UserCreationForm):
    def __init__(self, *args, **kwargs):
        super(CustomUserCreationForm,self).__init__(*args, **kwargs)

        try:
            if args[0]["email"]:
                self.email= args[0]["email"]
                self.password= args[0]["password1"]
        except:
            pass

    class Meta:
        model = CustomUser
        fields = "__all__"

    def save(self, commit=False,**kwargs):

        customer = stripe.Customer.create(
            email=self.email,
            name="test",
        )


        user = CustomUser.objects.create(email=self.email,password=self.password)

        user.set_password(self.password)
        user.save_m2m()
        return user

I get the error

'CustomUser' object has no attribute 'save_m2m'

Can someone please assist on how to solve this?

0 Answers
Related