Ask Your Question
4

Is it possible for me to generate an AbstractUser instance within my model class located in the model.py file of Django?

asked 2021-06-16 11:00:00 +0000

lalupa gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-11-26 15:00:00 +0000

ladyg gravatar image

Yes, it is possible to generate an AbstractUser instance within a model class located in the model.py file of Django. You can import the AbstractUser class from the django.contrib.auth.models module and then use it as a superclass for your custom model class. Your custom model class will inherit all the fields and methods defined in the AbstractUser class, which includes the username, password, and email fields, as well as methods for authentication and authorization.

However, it is recommended to use the AbstractUser class as a base class only for custom user models that require additional fields or methods. For a basic user model, you can use the built-in User model provided by Django instead of creating a new one.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-06-16 11:00:00 +0000

Seen: 12 times

Last updated: Nov 26 '22