Metadata-Version: 2.4
Name: django-visit-logger
Version: 0.1.0
Summary: Django visit collection API and read-only admin
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: Django>=4.2
Requires-Dist: djangorestframework
Requires-Dist: pycountry
Requires-Dist: user-agents

# Django Visits

Django Visits records page visits through Django REST Framework and lets staff
inspect them in Django admin.

Install with `python -m pip install django-visit-logger` or run
`python -m pip install .` from the repository root.
Add `django_visits` to `INSTALLED_APPS` and run
`python manage.py migrate`. `Visit.user` uses the project's `AUTH_USER_MODEL`.

Register the create-only viewset on your API router:

```python
from django_visits.views import VisitViewSet

router.register("visits", VisitViewSet)
```

The endpoint accepts a required `referrer` (which may be blank or null), an
optional `url`, nullable `cookies_accepted`, and an optional `analytics_enabled`
flag. It returns HTTP 201 with `{}` and uses the host's DRF authentication,
permission, and throttle settings. The view records the authenticated user, IP,
user agent, and configured request metadata. Django admin exposes visits to
staff with view permission.

Optional Django settings

- `VISITS_COUNTRY_HEADER` names a trusted proxy header in `request.META`.
  Country header lookup is off by default.
- `VISITS_COUNTRY_HEADER_ALPHA_FORMAT` selects the `pycountry` lookup field.
  It defaults to `alpha_2`.
- `VISITS_COUNTRY_CODE_OVERRIDES` maps proxy-specific codes to display names.
  It defaults to an empty mapping.
- `VISITS_EXTRA_HEADERS` lists additional `request.META` keys to store.
  It defaults to an empty list.

## Publishing

Run `.\publish.ps1 -BuildOnly` to build and validate the wheel and source
distribution. Run `.\publish.ps1 -Repository testpypi` to upload to TestPyPI,
or `.\publish.ps1` to upload to PyPI. Use `-Python` to select a virtualenv's
Python executable. Twine reads credentials from its environment, keyring, or
`.pypirc`.
