
Security News
November CVEs Fell 25% YoY, Driven by Slowdowns at Major CNAs
November CVE publications fell 25% YoY even as 2025 totals rose, showing how a few major CNAs can swing “global” counts and skew perceived risk.
django-earthdistance
Advanced tools
Using PostgreSQL's EarthDistance extension for django 1.11, 2.2 and 3.2 (for older versions see with_djorm_expressions branch)
Earthdistance allows to do fast geolocalized queries without using PostGIS
Cube and EarthDistance extensions must be enabled in postgreSQL BD, so log in database using pgsql and install extensions:
.. code:: sql
=> create extension cube;
=> create extension earthdistance;
.. code:: python
from django.db import models
from django_earthdistance.models import EarthDistanceQuerySet
class MyModel(models.Model):
latitute = models.FloatField()
longitude = models.FloatField()
objects = EarthDistanceQuerySet.as_manager()
# Define fields to query in DistanceExpression initialization
# search with lat=0.2546 and lon=-38.25 and distance 1500 meters
# use param `annotate` to set a custom field for the distance, `_ed_distance` as default
MyModel.objects.in_distance(1500, fields=['latitude', 'longitude'], points=[0.2546, -38.25])
.. code:: python
from django_earthdistance.models import EarthDistance, LlToEarth
MyModel.objects.filter(....).annotate(
distance=EarthDistance([
LlToEarth([0.2546, -38.25]),
LlToEarth(['latitude', 'longitude'])
]))
PostgreSQL allow to use GiST indexes with functions results, a good perfomance improvement is to store ll_to_earth results in
an index, ll_to_earth is a function that calculates the position of a point on the surface of the earth (assuming earth is
perfectly spherical)
.. code:: sql
-- Example MyModel table is app_mymodel and points columns are latitude and longitude
CREATE INDEX mymodel_location ON app_mymodel USING gist (ll_to_earth(latitude, longitude));
For django < 1.7
Also, using south is preferred, just add this migration to migrations/ folder and edit it to your needs, index will be created
.. code:: python
class Migration(SchemaMigration):
def forwards(self, orm):
cursor = connection.cursor()
cursor.execute("CREATE INDEX mymodel_location ON app_mymodel USING gist (ll_to_earth(latitude, longitude));")
def backwards(self, orm):
# Deleting field 'Venue.coords'
cursor = connection.cursor()
cursor.execute("DROP INDEX mymodel_location ON app_mymodel;")
FAQs
Add support for PostgreSQL earthdistance extension to Django
We found that django-earthdistance demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
November CVE publications fell 25% YoY even as 2025 totals rose, showing how a few major CNAs can swing “global” counts and skew perceived risk.

Security News
React disclosed a CVSS 10.0 RCE in React Server Components and is advising users to upgrade affected packages and frameworks to patched versions now.

Research
/Security News
We spotted a wave of auto-generated “elf-*” npm packages published every two minutes from new accounts, with simple malware variants and early takedowns underway.