Fields¶
-
class
osm_field.fields.
LatitudeField
(*args, **kwargs)¶ Bases:
django.db.models.fields.FloatField
Bases:
django.db.models.FloatField
The
validators
parameter will be appended withvalidate_latitude()
if not already present.-
formfield
(**kwargs)¶ - Returns
A
FloatField
withmax_value
90 andmin_value
-90.
-
-
class
osm_field.fields.
Location
(lat, lon, text)¶ Bases:
object
A wrapper class bundling the description of a location (
text
) and its geo coordinates, latitude (lat
) and longitude (lon
).- Parameters
lat (float) – The latitude
lon (float) – The longitude
str – The description
-
class
osm_field.fields.
LongitudeField
(*args, **kwargs)¶ Bases:
django.db.models.fields.FloatField
Bases:
django.db.models.FloatField
The
validators
parameter will be appended withvalidate_longitude()
if not already present.-
formfield
(**kwargs)¶ - Returns
A
FloatField
withmax_value
180 andmin_value
-180.
-
-
class
osm_field.fields.
OSMField
(*args, **kwargs)¶ Bases:
django.db.models.fields.TextField
Bases:
django.db.models.TextField
- Parameters
lat_field (str) – The name of the latitude field.
None
(and thus standard behavior) by default.lon_field (str) – The name of the longitude field.
None
(and thus standard behavior) by default.
-
check
(**kwargs)¶
-
contribute_to_class
(cls, name)¶ Register the field with the model class it belongs to.
If private_only is True, create a separate instance of this field for every subclass of cls, even if cls is not an abstract model.
-
deconstruct
()¶ Return enough information to recreate the field as a 4-tuple:
The name of the field on the model, if contribute_to_class() has been run.
The import path of the field, including the class, e.g. django.db.models.IntegerField. This should be the most portable version, so less specific may be better.
A list of positional arguments.
A dict of keyword arguments.
Note that the positional or keyword arguments must contain values of the following types (including inner values of collection types):
None, bool, str, int, float, complex, set, frozenset, list, tuple, dict
UUID
datetime.datetime (naive), datetime.date
top-level classes, top-level functions - will be referenced by their full import path
Storage instances - these have their own deconstruct() method
This is because the values here must be serialized into a text format (possibly new Python code, possibly JSON) and these are the only types with encoding handlers defined.
There’s no need to return the exact way the field was instantiated this time, just ensure that the resulting field is the same - prefer keyword arguments over positional ones, and omit parameters with their default values.
-
formfield
(**kwargs)¶ - Returns
A
OSMFormField
with aOSMWidget
.
-
property
latitude_field_name
¶ The name of the related
LatitudeField
.
-
property
longitude_field_name
¶ The name of the related
LongitudeField
.