mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-10 04:50:16 +02:00
29 lines
606 B
Markdown
29 lines
606 B
Markdown
# 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:
|
|
|
|
```python
|
|
from allianceauth.framework.api.user import get_sentinel_user
|
|
```
|
|
|
|
And later in your model:
|
|
|
|
```python
|
|
creator = models.ForeignKey(
|
|
to=User,
|
|
on_delete=models.SET(get_sentinel_user),
|
|
)
|
|
```
|