Took me a long long time to work out why the .kml file I created in
django would parse as valid in Feedburner but googlemaps said it was
an invalid kml file.  Need to be sending as correct content-type of
course.

In case anyone else is stuck, here is how I did it:

template
-----------
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1";>

  <Document>
    <name>Seed Trial Locations</name>
    <description>Where we are</description>


{% for location in locations %}
  <Placemark>
    <name>{% if location.name %}{{ location.name }}{% else %}
{{ location }}{% endif %}</name>
    <description>{% if location.description %}
{{ location.description }}{% else %}{{ location.name }}{% endif %}</
description>
    <Point>
        <coordinates>{{location.longt}},{{location.lat}}</coordinates>
    </Point>
  </Placemark>
{% endfor %}


</Document>
</kml>


view
====
def generateKml(request):

    locations = Location.objects.all().values('name','lat','longt')

    result= render_to_response('locations.kml',{
        'locations': locations
        })

    return HttpResponse(result,mimetype='Content-Type:application/
vnd.google-earth.kml+xml')

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to