[Answered ]-How can I make a user out of a model in Django?

1👍

You have commented username and password in your model, why ?

Password field already exists in the abstractbaseuser, so comment it does not remove it. The abstract model user of Django need a unique information for authenticating user. You can use a Username or an Email.

For using the email instead of username, you can define USERNAME_FIELD = "email" in your class. But you have to define a field email, or you keep username field and add it to fields ModelForm.

There is a constraint on the username field (or email field), so you have to define it for each Car_owner you want to create (it is for authenticating purpose).

your field id_owner is useless, Django create automatically a field called id in each model which is the primary key.

so for resolving your problem easily, add username in fields list of your Form for beginning.

Leave a comment