title: Converting geometry point to lat/long in Geodjango app
body: <p>I'm creating a web mapping application using Django, Geodjango, OpenLayers and PostGIS. I want to zoom on an OpenLayers basemap to the location of a city that has been selected from a combo box and I figure I can do this by passing lat/long coordinates and a zoom level to OpenLayers.</p>
  
  <p>I have a view function that runs a django query with a filter for the selected city and then I calculate the centroid for the returned QuerySet, as shown below.</p>
  
  <pre><code>centroid = LGA.objects.get(name=lga).geom.centroid
  </code></pre>
  
  <p>The way I am currently setting my map centre is statically with the following code:</p>
  
  <pre><code>var center = new OpenLayers.LonLat(133.0, -27.0).transform(
      new OpenLayers.Projection("EPSG:4326"),
      map.getProjectionObject()
      );
  </code></pre>
  
  <p>Those coordinates are for the centre of Australia, but I want to set the map centre dynamically for a selected city using a Django template with variables for the Lat and Long. I'm not sure how to get the Lat and Long from the centroid I calculate in my view function, or alternatively, if there is another way to set the map centre in OpenLayers by passing it a geometry rather than coordinates.</p>
  
  <p>Thanks in advance for any help.</p>
  
  <p>Ro</p>