Skip to content

Commit 8a17121

Browse files
author
Kostas Livieratos
committed
middleware doesn't assume the user has already set GEOIP_PATH
1 parent 95f0a47 commit 8a17121

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

django_traffic/middleware.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
def _load_geo_db():
1616
geo_db_path = getattr(settings, 'GEO_DB_PATH', None)
1717
if geo_db_path is None:
18-
# assume the user has set GEOIP_PATH in settings.py
19-
g = GeoIP2()
20-
else:
21-
g = GeoIP2(path=geo_db_path)
22-
return g
18+
if hasattr(settings, 'GEOIP_PATH'):
19+
g = GeoIP2()
20+
return g
21+
logging.error('[django-traffic] GEOIP_PATH or GEO_DB_PATH should be present in settings.py')
22+
return None
23+
return GeoIP2(path=geo_db_path)
2324

2425

2526
class ESTrafficInfoMiddleware(MiddlewareMixin):

0 commit comments

Comments
 (0)