mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-20 10:16:42 -06:00
Docs & changelog for #3705
This commit is contained in:
parent
84a2b726f5
commit
adeee0bf5c
@ -71,6 +71,18 @@ The checkbox to commit database changes when executing a script is checked by de
|
|||||||
commit_default = False
|
commit_default = False
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Accessing Request Data
|
||||||
|
|
||||||
|
Details of the current HTTP request (the one being made to execute the script) are available as the instance attribute `self.request`. This can be used to infer, for example, the user executing the script and the client IP address:
|
||||||
|
|
||||||
|
```python
|
||||||
|
username = self.request.user.username
|
||||||
|
ip_address = self.request.META.get('HTTP_X_FORWARDED_FOR') or self.request.META.get('REMOTE_ADDR')
|
||||||
|
self.log_info("Running as user {} (IP: {})...".format(username, ip_address))
|
||||||
|
```
|
||||||
|
|
||||||
|
For a complete list of available request parameters, please see the [Django documentation](https://docs.djangoproject.com/en/stable/ref/request-response/).
|
||||||
|
|
||||||
## Reading Data from Files
|
## Reading Data from Files
|
||||||
|
|
||||||
The Script class provides two convenience methods for reading data from files:
|
The Script class provides two convenience methods for reading data from files:
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
# v2.6.10 (FUTURE)
|
# v2.6.10 (FUTURE)
|
||||||
|
|
||||||
|
## Enhancements
|
||||||
|
|
||||||
|
* [#3705](https://github.com/netbox-community/netbox/issues/3705) - Provide request context when executing custom scripts
|
||||||
|
|
||||||
## Bug Fixes
|
## Bug Fixes
|
||||||
|
|
||||||
* [#3780](https://github.com/netbox-community/netbox/issues/3780) - Fix AttributeError exception in API docs
|
* [#3780](https://github.com/netbox-community/netbox/issues/3780) - Fix AttributeError exception in API docs
|
||||||
|
Loading…
Reference in New Issue
Block a user