Use get_user_model for reference to User #8152

Closed
opened 2025-12-29 20:33:08 +01:00 by adam · 0 comments
Owner

Originally created by @arthanson on GitHub (Jun 1, 2023).

Originally assigned to: @arthanson on GitHub.

Proposed Changes

There is a large number of places in the code that import and use the User model directly:

from django.contrib.auth.models import User

These should all be replaced with calls to get_user_model to facilitate the potential change to a custom User model.

Justification

See https://docs.djangoproject.com/en/4.2/topics/auth/customizing/#referencing-the-user-model - this is a requirement if we are going to potentially use a custom user model.

Originally created by @arthanson on GitHub (Jun 1, 2023). Originally assigned to: @arthanson on GitHub. ### Proposed Changes There is a large number of places in the code that import and use the User model directly: ``` from django.contrib.auth.models import User ``` These should all be replaced with calls to get_user_model to facilitate the potential change to a custom User model. ### Justification See https://docs.djangoproject.com/en/4.2/topics/auth/customizing/#referencing-the-user-model - this is a requirement if we are going to potentially use a custom user model.
adam added the status: acceptedtype: housekeeping labels 2025-12-29 20:33:08 +01:00
adam closed this issue 2025-12-29 20:33:08 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8152