Django Eve Universe
Django Eve Universe provides a complete set of Eve Universe models, allowing easy access to EVE Online universe data fetched on-demand from ESI. It enables storing, caching, and updating critical EVE Online static data within a Django project. The current version is 1.6.1, and it maintains an active release cadence with regular updates and bug fixes.
Common errors
-
django.db.utils.ProgrammingError: relation "eveuniverse_evetype" does not exist
cause Database migrations for `django-eveuniverse` have not been applied.fixRun `python manage.py migrate` to create the necessary database tables for `django-eveuniverse` models. -
EveType.DoesNotExist: EveType matching query does not exist.
cause The requested Eve Universe entity (e.g., 'Tritanium' for `EveType`) has not been loaded into your database.fixEnsure `EVEUNIVERSE_DATA_SOURCES` is correctly configured in your Django `settings.py` for the relevant entity, then run `python manage.py eveuniverse_load_data`. -
ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings have not been configured.
cause You are attempting to access `django-eveuniverse` models or settings outside of a properly initialized Django environment (e.g., in a standalone script without `django.setup()`).fixEnsure your script or application runs within a full Django environment. If it's a standalone script, use `django.setup()` after configuring `settings` and before importing Django models.
Warnings
- breaking Major breaking changes were introduced in version 1.0. The `EveEntity` model was renamed to `EveUniverseEntity`, and the `EveUniverseEntity` mixin was renamed to `EveUniverseEntityModel`.
- gotcha Data for Eve Universe entities (types, groups, systems, etc.) is not automatically loaded upon installation. You must configure `EVEUNIVERSE_DATA_SOURCES` in your Django settings and then run the management command `python manage.py eveuniverse_load_data`.
- gotcha Ensure your Django version meets the minimum requirement. `django-eveuniverse` v1.x requires Django >=3.2. Older versions had different compatibility requirements.
Install
-
pip install django-eveuniverse
Imports
- EveType
from eveuniverse.models import EveType
- EveSolarSystem
from eveuniverse.models import EveSolarSystem
- EVEUNIVERSE_DATA_SOURCES
from eveuniverse import EVEUNIVERSE_DATA_SOURCES
from django.conf import settings # Then access settings.EVEUNIVERSE_DATA_SOURCES
Quickstart
import os
import django
from django.conf import settings
# Minimal Django setup for quickstart demonstration
# In a real Django project, this setup is handled by manage.py
if not settings.configured:
settings.configure(
INSTALLED_APPS=['django.contrib.sites', 'eveuniverse'],
DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:'}},
SITE_ID=1,
EVEUNIVERSE_DATA_SOURCES={ # Configure at least one source for data loading
'eveuniverse.EveType': {'priority': 100, 'enabled': True}
}
)
django.setup()
from eveuniverse.models import EveType
# In a real setup, you would run 'python manage.py migrate'
# and then 'python manage.py eveuniverse_load_data' to populate the database.
# For this quickstart, we assume data is already present.
try:
# Example: Retrieve 'Tritanium' (a common EVE mineral)
tritanium = EveType.objects.get(name='Tritanium')
print(f"Found Tritanium: ID {tritanium.id}, Group: {tritanium.eve_group.name if tritanium.eve_group else 'N/A'}")
# Example: Retrieve 'Jita' solar system (which is an EveType)
jita_system_id = 30000142
jita_system = EveType.objects.get(id=jita_system_id)
print(f"Found Jita system: {jita_system.name}")
except EveType.DoesNotExist:
print("One or more Eve Types not found. Ensure you have run 'python manage.py eveuniverse_load_data' after setup.")
except Exception as e:
print(f"An error occurred: {e}")