Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# UNRELEASED

- Make `geoip2` an optional dependency. It can be installed using the `geoip2` extra.

# 2.0.0 (Feb 23, 2025)

- Add support for Python 3.13 and drop support for Python 3.8.
Expand Down
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,25 @@ migration script.
python manage.py migrate qsessions
```

To enable location detection using GeoIP2 (optional):
### Use GeoIP2 (optional)

5. Install `geoip2` package:
To enable location detection using GeoIP2, you'll need to follow a few extra steps:

1. Install `django-qsessions` with the `geoip2` extra:

```sh
pip install geoip2
pip install "django-qsessions[geoip2]"
```

6. Set `GEOIP_PATH` to a directory for storing GeoIP2 database.
2. Set `GEOIP_PATH` to a directory in Django settings for storing GeoIP2
database.

7. Run the following command to download latest GeoIP2 database. You
can add this command to a cron job to update GeoIP2 DB
3. Run the following command to download the latest GeoIP2 database. You
can add this command to a cron job to update the GeoIP2 DB
automatically. Due to [Maxmind license
changes](https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-geolite2-databases/)
changes](https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-geolite2-databases/),
you will need to acquire and use a license key for downloading the
databases. You can pass the key on the command line, or in the
databases. You can pass the key on the command line or in the
`MAXMIND_LICENSE_KEY` environment variable.

```sh
Expand Down
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@

dev_requirements = [
"pre-commit",
"geoip2", # for testing GeoIP2
"pytest>=7",
"pytest-cov",
"pytest-django",
]

geoip_requirements = ["geoip2>=4.1.0"]

setup(
name="django-qsessions",
version="2.0.0",
Expand All @@ -29,7 +30,10 @@
packages=find_packages(".", include=("qsessions", "qsessions.*")),
include_package_data=True,
install_requires=["Django >= 4.2", "ua-parser[regex] >= 1.0.1"],
extras_require={"dev": dev_requirements},
extras_require={
"dev": dev_requirements + geoip_requirements,
"geoip2": geoip_requirements,
},
tests_require=dev_requirements,
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand Down
Empty file added tests/__init__.py
Empty file.
Loading