import psycopg2
from srsbrowser.models import SRS

db = psycopg2.connect("dbname=sr.org.orig")
cur = db.cursor()

cur.execute("select srid, from_esri, views from spatial_ref_sys")
for row in cur.fetchall():
    (srs_id, type, views) = row
    if type == True:
        type = "esri"
    else: 
        type = "epsg"
    obj = SRS.objects.get(type=type,srs_id=srs_id) 
    obj.views = views
    obj.save()
    print "Saved views for %s (%s)" % (obj.srs_id, views)

