Autoreference

This document is an autogenerated reference for the django_owm package. It provides detailed information about the modules, classes, functions, and methods available in the package.

admin.py

Admin for the django_owm app.

apps.py

App configuration for the django_owm app.

class django_owm.apps.DjangoOwmConfig(app_name, app_module)[source]

App configuration for django-owm.

ready()[source]

Run when the app is ready.

app_settings.py

App settings for the django_owm app.

django_owm.app_settings.OWM_BASE_MODEL()

Get the base model for OWM models.

django_owm.app_settings.get_base_model()[source]

Get the base model for OWM models.

forms.py

Forms for django_owm.

class django_owm.forms.TrimmedDecimalField(*, max_value=None, min_value=None, max_digits=None, decimal_places=None, **kwargs)[source]

Custom DecimalField that trims the value to 2 decimal places.

to_python(value)[source]

Trim the value to 2 decimal places.

class django_owm.forms.WeatherLocationForm(*args, **kwargs)[source]

Form for creating or updating a Weather Location.

__init__(*args, **kwargs)[source]

Initialize the form.

clean_latitude()[source]

Clean the input latitude value.

clean_longitude()[source]

Clean the input longitude value.

property media

Return all media required to render the widgets on this form.

django_owm.forms.quantize_to_2_decimal_places(value)[source]

Quantize a Decimal value to 2 decimal places.

Parameters:

value (Decimal | str | None)

Return type:

Decimal | None

management/commands/

create_location.py

Management command to create a new weather location.

class django_owm.management.commands.create_location.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]

Management command to create a new weather location.

handle(*args, **options)[source]

Handle the command.

delete_location.py

Management command to delete a weather location.

class django_owm.management.commands.delete_location.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]

Management command to delete a weather location.

add_arguments(parser)[source]

Add arguments to the command.

handle(*args, **options)[source]

Handle the command.

list_locations.py

Management command to list all weather locations.

class django_owm.management.commands.list_locations.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]

Management command to list all weather locations.

handle(*args, **options)[source]

Handle the command.

manual_weather_fetch.py

Management command to manually fetch weather data for a specific location.

class django_owm.management.commands.manual_weather_fetch.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]

Management command to manually fetch weather data for a specific location.

add_arguments(parser)[source]

Add arguments to the command.

handle(*args, **options)[source]

Handle the command.

models/

abstract.py

Models for OpenWeatherMap API data storage in django_owm.

class django_owm.models.abstract.AbstractAPICallLog(*args, **kwargs)[source]

Abstract model for storing API call logs.

Parameters:
  • timestamp (DateTimeField) – timestamp

  • api_name (CharField) – api name

  • units (CharField) – Units

class UnitsType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Choices for the units type field.

class django_owm.models.abstract.AbstractCurrentWeather(*args, **kwargs)[source]

Abstract model for storing current weather data.

Parameters:
  • location_id (ForeignKey) – Location for this weather data

  • timestamp (DateTimeField) – Unix timestamp converted to DateTime

  • pressure (IntegerField) – pressure

  • humidity (IntegerField) – humidity

  • dew_point (DecimalField) – Dew Point

  • uvi (DecimalField) – UV Index

  • clouds (IntegerField) – clouds

  • wind_speed (DecimalField) – Wind Speed

  • wind_deg (IntegerField) – wind deg

  • wind_gust (DecimalField) – Wind Gust

  • weather_condition_id (IntegerField) – weather condition id

  • weather_condition_main (CharField) – weather condition main

  • weather_condition_description (CharField) – Icon description

  • weather_condition_icon (CharField) – weather condition icon

  • sunrise (DateTimeField) – sunrise

  • sunset (DateTimeField) – sunset

  • temp (DecimalField) – Temperature

  • feels_like (DecimalField) – Feels Like Temperature

  • visibility (IntegerField) – visibility

  • rain_1h (DecimalField) – Precipitation in mm/h

  • snow_1h (DecimalField) – Snowfall in mm/h

class django_owm.models.abstract.AbstractDailyWeather(*args, **kwargs)[source]

Abstract model for storing daily weather data.

Parameters:
  • location_id (ForeignKey) – Location for this weather data

  • timestamp (DateTimeField) – Unix timestamp converted to DateTime

  • pressure (IntegerField) – pressure

  • humidity (IntegerField) – humidity

  • dew_point (DecimalField) – Dew Point

  • uvi (DecimalField) – UV Index

  • clouds (IntegerField) – clouds

  • wind_speed (DecimalField) – Wind Speed

  • wind_deg (IntegerField) – wind deg

  • wind_gust (DecimalField) – Wind Gust

  • weather_condition_id (IntegerField) – weather condition id

  • weather_condition_main (CharField) – weather condition main

  • weather_condition_description (CharField) – Icon description

  • weather_condition_icon (CharField) – weather condition icon

  • sunrise (DateTimeField) – sunrise

  • sunset (DateTimeField) – sunset

  • moonrise (DateTimeField) – moonrise

  • moonset (DateTimeField) – moonset

  • moon_phase (DecimalField) – Moon Phase

  • summary (TextField) – summary

  • temp_min (DecimalField) – Temperature Min

  • temp_max (DecimalField) – Temperature Max

  • temp_morn (DecimalField) – Morning Temperature

  • temp_day (DecimalField) – Day Temperature

  • temp_eve (DecimalField) – Evening Temperature

  • temp_night (DecimalField) – Night Temperature

  • feels_like_morn (DecimalField) – Feels Like - Morning

  • feels_like_day (DecimalField) – Feels Like - Day

  • feels_like_eve (DecimalField) – Feels Like - Evening

  • feels_like_night (DecimalField) – Feels Like - Night

  • pop (DecimalField) – Probability of Precipitation

  • rain (DecimalField) – Rain

  • snow (DecimalField) – Snow

property moon_phase_description

Return a description of the moon phase.

class django_owm.models.abstract.AbstractHourlyWeather(*args, **kwargs)[source]

Abstract model for storing hourly weather data.

Parameters:
  • location_id (ForeignKey) – Location for this weather data

  • timestamp (DateTimeField) – Unix timestamp converted to DateTime

  • pressure (IntegerField) – pressure

  • humidity (IntegerField) – humidity

  • dew_point (DecimalField) – Dew Point

  • uvi (DecimalField) – UV Index

  • clouds (IntegerField) – clouds

  • wind_speed (DecimalField) – Wind Speed

  • wind_deg (IntegerField) – wind deg

  • wind_gust (DecimalField) – Wind Gust

  • weather_condition_id (IntegerField) – weather condition id

  • weather_condition_main (CharField) – weather condition main

  • weather_condition_description (CharField) – Icon description

  • weather_condition_icon (CharField) – weather condition icon

  • temp (DecimalField) – Temperature

  • feels_like (DecimalField) – Feels Like Temperature

  • visibility (IntegerField) – visibility

  • pop (DecimalField) – Probability of Precipitation

  • rain_1h (DecimalField) – Rain (1h)

  • snow_1h (DecimalField) – Snow (1h)

class django_owm.models.abstract.AbstractMinutelyWeather(*args, **kwargs)[source]

Abstract model for storing minutely weather data.

Parameters:
  • location_id (ForeignKey) – Location for this weather data by minute

  • timestamp (DateTimeField) – Unix timestamp converted to DateTime

  • precipitation (DecimalField) – Precipitation

class django_owm.models.abstract.AbstractWeatherAlert(*args, **kwargs)[source]

Abstract model for storing weather alerts.

Parameters:
  • location_id (ForeignKey) – location

  • sender_name (CharField) – sender name

  • event (CharField) – event

  • start (DateTimeField) – Start time of the alert

  • end (DateTimeField) – End time of the alert

  • description (TextField) – description

  • tags (JSONField) – tags

class django_owm.models.abstract.AbstractWeatherErrorLog(*args, **kwargs)[source]

Abstract model for storing weather API error logs.

Parameters:
  • timestamp (DateTimeField) – timestamp

  • location_id (ForeignKey) – location

  • api_name (CharField) – api name

  • error_message (TextField) – error message

  • response_data (TextField) – response data

class django_owm.models.abstract.AbstractWeatherLocation(*args, **kwargs)[source]

Abstract model for storing weather location data.

Parameters:
  • name (CharField) – Location Name

  • latitude (DecimalField) – Latitude of the location, decimal (−90; 90)

  • longitude (DecimalField) – Longitude of the location, decimal (−180; 180)

  • timezone (CharField) – Timezone name for the requested location

  • timezone_offset (IntegerField) – Offset from UTC in seconds

base.py

Base Models for django_owm. These are not meant to be used directly.

class django_owm.models.base.AbstractBaseWeatherData(*args, **kwargs)[source]

Abstract base model for storing weather data. Not intended to be used directly.

Parameters:
  • location_id (ForeignKey) – Location for this weather data

  • timestamp (DateTimeField) – Unix timestamp converted to DateTime

  • pressure (IntegerField) – pressure

  • humidity (IntegerField) – humidity

  • dew_point (DecimalField) – Dew Point

  • uvi (DecimalField) – UV Index

  • clouds (IntegerField) – clouds

  • wind_speed (DecimalField) – Wind Speed

  • wind_deg (IntegerField) – wind deg

  • wind_gust (DecimalField) – Wind Gust

  • weather_condition_id (IntegerField) – weather condition id

  • weather_condition_main (CharField) – weather condition main

  • weather_condition_description (CharField) – Icon description

  • weather_condition_icon (CharField) – weather condition icon

property icon_url

Return the URL for the weather condition icon.

property large_icon_url

Return the URL for the weather condition icon.

property weather_description

Return the weather description.

https://openweathermap.org/weather-conditions

concrete.py

Optional concrete models for django_owm app.

tasks.py

Celery tasks for fetching weather data from OpenWeatherMap API for django_owm.

(task)django_owm.tasks.fetch_weather(location_ids: decimal.Decimal | int | None = None) None[source]

Fetch current weather data for all locations.

Parameters:

location_ids (Decimal | int | None)

Return type:

None

urls.py

URLs for the django_owm app.

utils/

api.py

Utility functions for working with the OpenWeatherMap API.

django_owm.utils.api.check_api_limits(func)[source]

Decorator to check API call limits before running a task.

Parameters:

func (Callable)

Return type:

Callable

django_owm.utils.api.get_api_call_counts(api_name)[source]

Get the number of API calls made in the last minute and last month.

Parameters:

api_name (str)

Return type:

tuple[int, int]

django_owm.utils.api.log_api_call(api_name)[source]

Log an API call to the database.

Parameters:

api_name (str)

Return type:

None

django_owm.utils.api.make_api_call(lat, lon, exclude=None)[source]

Make an API call to OpenWeatherMap.

Parameters:
Return type:

dict | None

saving.py

Utility functions for saving weather data to the database.

django_owm.utils.saving.save_alerts(location, data)[source]

Save weather alerts to the database.

Parameters:
Return type:

None

django_owm.utils.saving.save_current_weather(location, data)[source]

Save current weather data to the database.

Parameters:
Return type:

None

django_owm.utils.saving.save_daily_weather(location, data)[source]

Save daily weather data to the database.

Parameters:
Return type:

None

django_owm.utils.saving.save_error_log(location, api_name, error_message, response_data=None)[source]

Save error log to the database.

Parameters:
Return type:

None

django_owm.utils.saving.save_hourly_weather(location, data)[source]

Save hourly weather data to the database.

Parameters:
Return type:

None

django_owm.utils.saving.save_minutely_weather(location, data)[source]

Save minutely weather data to the database.

Parameters:
Return type:

None

django_owm.utils.saving.save_weather_data(location, data)[source]

Save weather data to the database.

Parameters:
Return type:

None

validators.py

Validators for the models of the django_owm app.

django_owm.validators.validate_latitude(value)[source]

Validate that the latitude is between -90 and 90.

django_owm.validators.validate_longitude(value)[source]

Validate that the longitude is between -180 and 180.

views.py

Views for the django_owm app.

django_owm.views.create_location(request)[source]

View to create a new weather location.

django_owm.views.delete_location(request, location_id)[source]

View to delete a weather location.

Parameters:

location_id (int | UUID)

django_owm.views.list_locations(request)[source]

View to display a list of all weather locations with an optional map.

django_owm.views.update_location(request, location_id)[source]

View to update a weather location.

Parameters:

location_id (int | UUID)

django_owm.views.weather_alerts(request, location_id)[source]

View to display weather alerts for a location.

Parameters:

location_id (int | UUID)

django_owm.views.weather_alerts_partial(request, location_id)[source]

Partial view to display weather alerts for a location inside weather_detail.html.

Parameters:

location_id (int | UUID)

django_owm.views.weather_detail(request, location_id)[source]

View to display the weather details for a location.

Parameters:

location_id (int | UUID)

django_owm.views.weather_errors(request, location_id)[source]

View to display weather errors for a location.

Parameters:

location_id (int | UUID)

django_owm.views.weather_errors_partial(request, location_id)[source]

Partial view to display weather errors for a location inside weather_detail.html.

Parameters:

location_id (int | UUID)

django_owm.views.weather_forecast(request, location_id)[source]

View to display weather forecast for a location.

Parameters:

location_id (int | UUID)

django_owm.views.weather_forecast_partial(request, location_id)[source]

Partial view to display weather forecast for a location inside weather_detail.html.

Parameters:

location_id (int | UUID)

django_owm.views.weather_history(request, location_id)[source]

View to display historical weather data for a location.

Parameters:

location_id (int | UUID)

django_owm.views.weather_history_partial(request, location_id)[source]

Partial view to display historical weather data for a location inside weather_detail.html.

Parameters:

location_id (int | UUID)