Peter Pfeufer 33ad1413d5
[ADD] Attempt to explain the sentinel user function
Let's see if the docs are generated properly with this
2023-12-17 23:50:13 +01:00

606 B

Alliance Auth Helper-Functions API

User API

get_main_character_from_user

get_main_character_name_from_user

get_sentinel_user

This function is useful in models when using User model-objects as foreign keys. Django needs to know what should happen to those relations when the user is being deleted. To keep the data, you can have Django map this to the sentinel user.

Import:

from allianceauth.framework.api.user import get_sentinel_user

And later in your model:

creator = models.ForeignKey(
    to=User,
    on_delete=models.SET(get_sentinel_user),
)