Skip to main content

Django app for importing and managing OpenFlights data (airports, airlines, routes)

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_openflights-0.1.0.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_openflights-0.1.0-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

File details

Details for the file django_openflights-0.1.0.tar.gz.

File metadata

  • Download URL: django_openflights-0.1.0.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_openflights-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8fe0500098d11df9ee570580c5f92b441780e551312c05c1979f294de2366ad0
MD5 43df381197e2773fb8cd27f23a3ea02b
BLAKE2b-256 1a2113c9ce9321de151290a76bf9324c14df4cf097e8de17603fb8eb91f10354

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_openflights-0.1.0.tar.gz:

Publisher: publish.yml on arthanson/django-openflights

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_openflights-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_openflights-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 11d464cc7769af91b4ab61a7dc4328f19206f79a96cfa950b7fec359a3c406d0
MD5 ad49c28447dab1a1e001ee3e8faba4e7
BLAKE2b-256 b348374c8253a41a31caa56ad1b31633ffa07041514bddf4c0c810331ead866d

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_openflights-0.1.0-py3-none-any.whl:

Publisher: publish.yml on arthanson/django-openflights

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page