title: convert PostGIS point object to geoJSON for mapping
body: <p>I have a Django app with a postgres db of PostGIS activities I'm trying to map on a frontend view using leaflet and Mapbox. </p>
  
  <p>I'm serializing the activities in the view and rendering them in the template as geoJSON (<code>{{ props.activitiesJson|safe }}</code>) </p>
  
  <p>[can render this as html and see the JSON objects on the page]. </p>
  
  <p>views.py (ex)</p>
  
  <pre><code>def map(request):
  
      mapbox_key = settings.MAPBOX_API_KEY
      activities = Activity.get_activities_near(lat, lng, radius)
  
      props = {'activitiesJson' : serializers.serialize('geojson', activities),}
  
      context = {
      'props' : props,
      'mapbox_key': mapbox_key
  }
  
  return render(request, 'app/map.html', context) 
  </code></pre>
  
  <p>template:</p>
  
  <pre><code>var map_activities = JSON.parse("{{ props.activitiesJson }}");
  L.geoJSON(map_activities).addTo(map); 
  </code></pre>
  
  <p>if I render <code>{{ props.activitiesJson }}</code> or <code>{{ props.activitiesJson|safe }}</code> directly on the template (not inside a script or parsing it) I see this data structure:</p>
  
  <pre><code>{"type": "FeatureCollection", "crs": {"type": "name", "properties": {"name": "EPSG:4326"}}, "features": [{"type": "Feature", "properties": {"cause": 1, "name": "Test Action", "slug": "test-action", "is_active": true, "image": "test.jpeg", "description": "test description", "date_start": null, "date_end": null, "skills_required": false, "on_site": false, "address_street": "123 Main St.", "address_street_2": "", "address_city": "New York", "address_state": "NY", "address_zip": "10013", "address_country": "", "location_city": "", "location_state": "", "location_country": "", "skills_list": [], "pk": "1"}, "geometry": null}]}
  </code></pre>
  
  <p>but trying to parse it with JSON.parse() throws a syntax err:</p>
  
  <pre><code>JSON.parse: expected property name or '}' at line 1 column 2 of the JSON data 
  </code></pre>
  
  <p>how do I validly assign that geoJSON object to my map_activities var? do I need to parse it at all? (i.e., <code>var map_activities = {{ props.activitiesJson|safe }};</code>)</p>
  
  <p>thanks</p>