Installation
Requirements
Django-Logbox requires:
Python 3.8 or higher
Django 3.2 or higher
Installation Steps
Install the package using pip:
pip install django-logbox
Add
django_logbox
to yourINSTALLED_APPS
in your Django settings file:INSTALLED_APPS = [ # ... 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # ... 'django_logbox', # ... ]
Add the Django-Logbox middleware to your
MIDDLEWARE
setting:MIDDLEWARE = [ # ... 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', # ... 'django_logbox.middlewares.LogboxMiddleware', # ... ]
Note
The position of the middleware in the list matters. For capturing all possible exceptions, it’s recommended to place the LogboxMiddleware after Django’s built-in middlewares.
Run migrations to create the necessary database tables:
python manage.py migrate django_logbox
(Optional) Configure Django-Logbox settings in your Django settings file:
LOGBOX_SETTINGS = { # Your custom settings here # See the Settings section for available options }
Verifying Installation
To verify that Django-Logbox is properly installed and working:
Start your Django development server:
python manage.py runserver
Make a request to any page in your application.
Check the Django admin interface at
/admin/django_logbox/serverlog/
to see if the request was logged.
Upgrading
To upgrade Django-Logbox to the latest version:
pip install --upgrade django-logbox
After upgrading, always run migrations to apply any database changes:
python manage.py migrate django_logbox