#36988: Limitation of supported GeoIP databases is too tight
------------------------+---------------------------------------
Reporter: rami | Owner: SnippyCodes
Type: Bug | Status: assigned
Component: GIS | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
------------------------+---------------------------------------
Comment (by SnippyCodes):
Following up on the PR review, we need a way to allow users to utilize
valid paid/custom GeoIP databases (like DBIP-Country or Geoacumen-Country)
without relying on fragile substring matching or adding a new global
Django setting.
Here are two potential API approaches for the community to consider:
**Option A: Instance-Level Configuration**
Allow developers to pass a custom list of supported types directly when
initializing the GeoIP2 object.
API: GeoIP2(supported_types=["DBIP-Country", "Geoacumen-Country"])
Pros: Explicit, localized to where the object is used, doesn't pollute
global settings.
Cons: Users might have to wrap the GeoIP2 instantiation if they use it in
multiple places across their app.
**Option B: "Bless" the AppConfig Modification**
Keep SUPPORTED_DATABASE_TYPES as a module-level set (as it currently is),
but officially document the recommended way for users to extend it inside
their AppConfig.ready() method.
API: ```python
from django.contrib.gis.geoip2 import SUPPORTED_DATABASE_TYPES
class MyGISAppConfig(AppConfig):
def ready(self):
SUPPORTED_DATABASE_TYPES.add("DBIP-Country")
I am happy to implement either of these, or another approach if the
community prefers. What are your thoughts?
--
Ticket URL: <https://code.djangoproject.com/ticket/36988#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/0107019d09713dad-b9feb37a-e194-40fa-b786-a81bcbc01cd7-000000%40eu-central-1.amazonses.com.