diff --git a/docs/development/custom/aa-framework.md b/docs/development/custom/aa-framework.md index 924026fe..07d99cd9 100644 --- a/docs/development/custom/aa-framework.md +++ b/docs/development/custom/aa-framework.md @@ -7,5 +7,6 @@ Alliance Auth is providing its own CSS framework with a couple of CSS classes. .. toctree:: :maxdepth: 1 + framework/api framework/css ``` diff --git a/docs/development/custom/framework/api.md b/docs/development/custom/framework/api.md new file mode 100644 index 00000000..ab539803 --- /dev/null +++ b/docs/development/custom/framework/api.md @@ -0,0 +1,28 @@ +# 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), +) +```