Skip to main content

Django IP logger

Django application for saving IP adresses visiting a web application.

Intro

As your web application scales, you will often encounter different reasons to keep track of IP Addresses. Perhaps, you just rolled out an Advert application and need to track visits and interactions in the back-end; perhaps, an 'evil' IP address continously pesters your endpoints without provocation and you'd like to implement a blacklist; better still, you need to track visitors across web pages on a 'IP' basis rather than just sessions.

Or perhaps, you have this biting need to have fun and fill production DBs with IP adresses whether you need it or not.

This application is a quite simple and effective solution to that.

How to do?

It's quite simple to use. Install with: pip install django-ip-logger

Next step is to add ip_logger to your INSTALLED_APPS like so:

INSTALLED_APPS = [
    #... apps I don't care about here
    'ip_logger',
]

Next is to add ip_logger.middleware.LogIPMiddleware to the top of the list of MIDDLEWARES:

MIDDLEWARE = [
    'ip_logger.middleware.LogIPMiddleware',
    # ... stuffs that's not my business
]

Working?

To test it's working, visit a random URL on your webapp and check that your IP has been added to the list.

FAQs

  1. Why don't you save other stuffs like requests, responses, response time, queries, url paths and the sorts? For the sake of generalization and to prevent bloating, I've decided to save only IPs, first visit and recent visit time. This is to ensure your DB is not populated with lots of rows for the sake of 'robust-ness'. Most web apps won't need it. If you do, implement it yourself, you've got the IPAdress model there for you.

  2. Do I need additional configurations? No, boss... You don't.

  3. Nothing's working, I've tried every possible option Quit the project, it's not worth it.

  4. This stuff is too simple, why implement it? Since you didn't implement it, I did.

  5. Why did you choose this name for the package? Don't question my decisions. It took me 3 days to make this decision.

  6. Is this package needed? Depends.

Bugs?

Raise an issue, I'll check it out.

Contributions?

Oh well... Make a PR

Metadata

Release files for django-ip-logger 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-ip-logger 1.0.1
File Size Uploaded
django-ip-logger-1.0.1.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-ip-logger 1.0.1
File Interpreter ABI Platform
django_ip_logger-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.5 kB

Release files / django-ip-logger-1.0.1.tar.gz

Download URL django-ip-logger-1.0.1.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c603e77defde7c335b90031453c2e89efdf5aca70fca242af480ff2444b1a40c
BLAKE2b-256 checksum
How to use checksums
5cac8db18239aeb84ec079cc8009f548dfc3e804882dd4ee62c0a364b46ed166
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.6

Release files / django_ip_logger-1.0.1-py3-none-any.whl

Download URL django_ip_logger-1.0.1-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
93e26cbde81681a780618784e10e2d39afd435c4ff2f0e4151cfbfc1a09d2fc6
BLAKE2b-256 checksum
How to use checksums
b8ac7c635881116ec5106b290c2cc75aada942434f5692080d4d4fcd17ea4bc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.6

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page