Skip to main content

Django model for storing HttpRequest information.

Project description

# Django Request Log

Simple Django model for logging HttpRequest instances.

**Compatibility:** Python 3.12+ and Django 5.2-6.0

## Why?

We have a number of libraries that store elements of a request (path,
querystring, user, response code, remote_addr, and so on), and it seemed
like time to create a single model that we can use in all of them,
storing a common set of values.

This is not a replacement for web server logs - it's a utility for use
in specific situations where you want to accurately log that someone
requested something.

## How it works

There is a single model, `RequestLog` and a model manager with a
`create` method that can take in a standard `HttpRequest` and / or
`HttpResponse` object and create a new `RequestLog` object. If you
are using this to record view functions, there is also a decorator,
`log_request` that will take care of all this for you:

```python
from request_logger.decorators import log_request

@log_request("downloads")
def download(request: HttpRequest) -> HttpReponse:
return HttpResponse("OK")


@log_request(lambda r: r.user.get_full_name())
def download(request: HttpRequest) -> HttpReponse:
return HttpResponse("OK")
```

The `log_request` argument is mandatory and is used as a "reference",
or category classifier. It can be a str, or a callable which takes
in the request as a single arg.

## Screenshots

**Admin list view**

<img src="screenshots/admin-list.png">

**Admin item view**

<img src="screenshots/admin-edit.png">

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_request_logger_2-0.5.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_request_logger_2-0.5.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file django_request_logger_2-0.5.0.tar.gz.

File metadata

  • Download URL: django_request_logger_2-0.5.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for django_request_logger_2-0.5.0.tar.gz
Algorithm Hash digest
SHA256 a0bcbcdd055f898c65b2f7dadd59fedd7041179c3fc24d63edabd312120c1dcb
MD5 9bf27999f3d4374158649e21df19f96c
BLAKE2b-256 88dc0b9508068a35924ff39c0273058bf1e3f0448b706feaa94d3df0c3872f16

See more details on using hashes here.

File details

Details for the file django_request_logger_2-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_request_logger_2-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ecd9bd2c1e6189f27bcb5d1a9bdc1e6114b05a813d0e59195ba67471776a587a
MD5 278cd8437d1da705b0d1a13e46ecf3e3
BLAKE2b-256 8d2ee99a9c657722c5ff5c036a67fcf94ebbfe2a67df88f2bae01b10f57be2b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page