Django now has the ability to use its model instead of contrib.auth.models.User


    Six years after the appearance of the ticket with the proposal to use your model instead of the standard django.contrib.auth.models.User and thousands of posts with ideas for using an additional profile model, a miracle happened:

    Now the user model is specified in the project settings:

    AUTH_USER_MODEL = 'auth.User'

    And to create a ForeignKey for a user model, they suggest using the following method:

    user = models.ForeignKey(settings.AUTH_USER_MODEL)

    At the same time, it is separately recommended to consider the need to store all user information that is not related to authorization in one model. Perhaps the best way to store such data would be the good old way with additional models; This will allow each application to have its own user information without the risk of conflicts with other applications.

    The rest of the documentation on the new functionality is already on the site:

    Those who are eager to try out the long-awaited feature in action can already use the trunk repository, for fans stability will have to wait for django 1.5.

    Also popular now: