In [2]: qs = City.objects.annotate(kml=AsKML('point'))
In [3]: qs.first().kml
Out[3]: u'<Point><coordinates>1,1</coordinates></Point>'
In [4]: qs.first().kml
In [5]: qs.first().kml
---------------------------------------------------------------------------
OperationalError Traceback (most recent call last)
<ipython-input-5-e1dac47e2e4f> in <module>()
----> 1 qs.first().kml
/home/sergey/dev/django/django/db/models/query.pyc in first(self)
558 Returns the first object of a query, returns None if no match is found.
559 """
--> 560 objects = list((self if self.ordered else self.order_by('pk'))[:1])
561 if objects:
562 return objects[0]
/home/sergey/dev/django/django/db/models/query.pyc in __iter__(self)
247 - Responsible for turning the rows into model objects.
248 """
--> 249 self._fetch_all()
250 return iter(self._result_cache)
251
/home/sergey/dev/django/django/db/models/query.pyc in _fetch_all(self)
1072 def _fetch_all(self):
1073 if self._result_cache is None:
-> 1074 self._result_cache = list(self.iterator())
1075 if self._prefetch_related_lookups and not self._prefetch_done:
1076 self._prefetch_related_objects()
/home/sergey/dev/django/django/db/models/query.pyc in __iter__(self)
50 # Execute the query. This will also fill compiler.select, klass_info,
51 # and annotations.
---> 52 results = compiler.execute_sql()
53 select, klass_info, annotation_col_map = (compiler.select, compiler.klass_info,
54 compiler.annotation_col_map)
/home/sergey/dev/django/django/db/models/sql/compiler.pyc in execute_sql(self, result_type)
827 cursor = self.connection.cursor()
828 try:
--> 829 cursor.execute(sql, params)
830 except Exception:
831 cursor.close()
/home/sergey/dev/django/django/db/backends/utils.pyc in execute(self, sql, params)
77 start = time()
78 try:
---> 79 return super(CursorDebugWrapper, self).execute(sql, params)
80 finally:
81 stop = time()
/home/sergey/dev/django/django/db/backends/utils.pyc in execute(self, sql, params)
62 return self.cursor.execute(sql)
63 else:
---> 64 return self.cursor.execute(sql, params)
65
66 def executemany(self, sql, param_list):
/home/sergey/dev/django/django/db/utils.pyc in __exit__(self, exc_type, exc_value, traceback)
92 if dj_exc_type not in (DataError, IntegrityError):
93 self.wrapper.errors_occurred = True
---> 94 six.reraise(dj_exc_type, dj_exc_value, traceback)
95
96 def __call__(self, func):
/home/sergey/dev/django/django/db/backends/utils.pyc in execute(self, sql, params)
62 return self.cursor.execute(sql)
63 else:
---> 64 return self.cursor.execute(sql, params)
65
66 def executemany(self, sql, param_list):
/home/sergey/dev/django/django/db/backends/sqlite3/base.pyc in execute(self, query, params)
327 return Database.Cursor.execute(self, query)
328 query = self.convert_query(query)
--> 329 return Database.Cursor.execute(self, query, params)
330
331 def executemany(self, query, param_list):
OperationalError: wrong number of arguments to function AsKML()
PR