Skip to main content

django-openflights

A Django application for importing and managing OpenFlights aviation data.

Provides models for airports, train stations, ferry ports, airlines, and aircraft types.

Features

  • Transport Hubs: Airports, train stations, and ferry ports with coordinates and codes
  • Airlines: Airline information with IATA/ICAO codes and operational status
  • Aircraft: Aircraft type codes and names
  • PostGIS Support: Full geometry support for spatial queries
  • Extensible: Plugin system for custom import processing

Note: Route data is not included as OpenFlights no longer maintains route information.

Compatibility

Python Django Database
3.10+ 4.2+ PostgreSQL with PostGIS
3.11+ 5.0+
3.12+ 5.1+

Quick Start

# Install
pip install django-openflights

# Add to INSTALLED_APPS
# 'django.contrib.gis',
# 'openflights',

# Run migrations
python manage.py migrate openflights

# Import all data
python manage.py openflights --import=all

Installation

pip install django-openflights

Add to your Django settings:

INSTALLED_APPS = [
    # ...
    'django.contrib.gis',
    'openflights',
]

Run migrations:

python manage.py migrate openflights

Usage

Import Data

# Import everything
python manage.py openflights --import=all

# Import specific data types
python manage.py openflights --import=airport,airline

# Import airports only (includes train stations and ports)
python manage.py openflights --import=airport

# Force re-download
python manage.py openflights --import=all --force

# Flush existing data before import
python manage.py openflights --flush=all --import=all

Query Data

from openflights.models import Airport, Airline

# Find airports by IATA code
sfo = Airport.objects.get(iata='SFO')
jfk = Airport.objects.get(iata='JFK')

# Find airports in a country
us_airports = Airport.objects.filter(country_name='United States')

# Find active airlines
active_airlines = Airline.objects.filter(is_active=True)

Spatial Queries

from django.contrib.gis.geos import Point
from django.contrib.gis.db.models.functions import Distance

# Find airports near a point
point = Point(-122.4194, 37.7749, srid=4326)
nearby = Airport.objects.filter(
    location__isnull=False
).annotate(
    distance=Distance('location', point)
).order_by('distance')[:10]

Models

Airport / TrainStation / Port

Transport hub models with shared fields:

Field Type Description
openflights_id Integer OpenFlights unique ID
name String Hub name
iata String 3-letter IATA code
icao String 4-letter ICAO code
location Point Geographic coordinates
altitude Float Altitude in meters
city_name String City name
country_name String Country name
timezone String IANA timezone

Airline

Field Type Description
openflights_id Integer OpenFlights unique ID
name String Airline name
iata String 2-letter IATA code
icao String 3-letter ICAO code
callsign String Radio callsign
country_name String Country of origin
is_active Boolean Currently operating

Aircraft

Field Type Description
name String Full aircraft name
iata String IATA type code
icao String ICAO type designator

Configuration

# Data directory for downloads
OPENFLIGHTS_DATA_DIR = '/path/to/data'

# What to import by default
OPENFLIGHTS_IMPORT_AIRPORTS = True
OPENFLIGHTS_IMPORT_AIRLINES = True
OPENFLIGHTS_IMPORT_PLANES = True

# Import geometry (disable for faster imports)
OPENFLIGHTS_IMPORT_GEOMETRY = True

# Custom plugins
OPENFLIGHTS_PLUGINS = ['myapp.plugins.MyPlugin']

Data Source

Data is sourced from OpenFlights, which provides:

  • ~14,000+ airports, train stations, and ferry terminals
  • ~6,000+ airlines
  • ~300+ aircraft types

Note: Route data was previously available but is no longer maintained by OpenFlights.

OpenFlights data is released under the Open Database License (ODbL).

Disclaimer

This project is not affiliated with, endorsed by, or associated with OpenFlights or its maintainers. It is an independent, third-party Django integration that consumes publicly available OpenFlights data.

License

MIT License

Links

Metadata

Release files for django-openflights 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-openflights 0.1.0
File Size Uploaded
django_openflights-0.1.0.tar.gz 22.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-openflights 0.1.0
File Interpreter ABI Platform
django_openflights-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 51.1 kB

Release files / django_openflights-0.1.0.tar.gz

Download URL django_openflights-0.1.0.tar.gz
Size 22.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8fe0500098d11df9ee570580c5f92b441780e551312c05c1979f294de2366ad0
BLAKE2b-256 checksum
How to use checksums
1a2113c9ce9321de151290a76bf9324c14df4cf097e8de17603fb8eb91f10354
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 3, 2026.

Transparency log

Release files / django_openflights-0.1.0-py3-none-any.whl

Download URL django_openflights-0.1.0-py3-none-any.whl
Size 28.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
11d464cc7769af91b4ab61a7dc4328f19206f79a96cfa950b7fec359a3c406d0
BLAKE2b-256 checksum
How to use checksums
b348374c8253a41a31caa56ad1b31633ffa07041514bddf4c0c810331ead866d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 3, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page