I already started to do this, but I stumbled on not knowing how to get the coordinate list from the objects (as returned by MyModel.objects.all()):
here is how a polygon should be represented in kml:
<Placemark>
<name>Some name</name>
<description>some description;</description>
<Style><PolyStyle><color>#80800000</color><fill>1</fill><outline>1</outline></PolyStyle></Style>
<MultiGeometry><Polygon><outerBoundaryIs><LinearRing><coordinates>-43.196591925838263,-22.897680139398773,0 -43.196362794169808,-22.89775202483413,0 -43.196125645784612,-22.898010711498866,0 -43.195790202127043,-22.897983609066173,
...
-43.198007179590775,-22.898279897020856,0 -43.197726669648162,-22.898000439337203,0 -43.1974422846057,-22.898050753172235,0 -43.196591925838263,-22.897680139398773,0</coordinates></LinearRing></outerBoundaryIs></Polygon></MultiGeometry>
</Placemark>
In order to cook my own kml, I need to be able to fetch the coordinates list of the points defining the polygon.
Playing around in the django shell I found the the above KML code is stored in the attribute object.geom.kml:
for example:
listofpols = MyModel.objects.all()
listofpols[0].geom.kml #this gives you the kml above!!!!
thanks for the hints, I think this is all I needed to write a correct kml template for polygons.
Flávio