website/docs: added example for custom user attributes (#2406)

* added example for custom user attributes

* simplified example

Co-authored-by: croudsarabi <constantin.roudsarabi@andrena.de>
This commit is contained in:
CRoudsarabi 2022-03-15 18:12:02 +01:00 committed by GitHub
parent b7a6fccdf9
commit 0f56d00959
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -0,0 +1,9 @@
- `user`: The current user. This may be `None` if there is no contextual user. See ([User](../user-group/user.md#object-attributes))
Example:
```python
return {
"custom_attribute": request.user.attributes.get("custom_attribute", "default"),
}
```

View File

@ -17,6 +17,9 @@ import Objects from '../expressions/_objects.md'
<Objects />
- `user`: The current user. This may be `None` if there is no contextual user. See ([User](../user-group/user.md#object-attributes))
import User from '../expressions/_user.md'
<User />
- `request`: The current request. This may be `None` if there is no contextual request. See ([Django documentation](https://docs.djangoproject.com/en/3.0/ref/request-response/#httprequest-objects))
- Other arbitrary arguments given by the provider, this is documented on the Provider/Source.