Django

class vectorformats.Formats.Django.Django(*args, **kwargs)

This class is designed to decode a Django QuerySet object into Feature.Vector objects.

Simply pass a query_set to the decode method, and it will return a list of Features.

Example Usage:

>>> from vectorformats.Formats import Django, GeoJSON
>>> qs = Model.objects.filter(city="Cambridge")
>>> djf = Django.Django(geodjango="geometry", properties=['city', 'state'])
>>> geoj = GeoJSON.GeoJSON()
>>> string = geoj.encode(djf.decode(qs))
>>> print string 
geodjango
If you have GeoDjango geometry columns, set this to the name of the geometry column.
pickled_geometry
If you are not using GeoDjango, but have instead stored your geometry as pickled GeoJSON geometries in a column in GeoDjango, set the pickled_geometry=True option in your class constructor.
pickled_properties
A column in the database representing a pickled set of attributes. This will be used in addition to any properties in the ‘properties’ list, with the list as a preference.
properties
List of properties you want copied from the model to the output object.

Previous topic

CSV

Next topic

Format

This Page