取得すると、すべてのジオメトリ オブジェクトを含む GeoQuerySet が取得されます
qs = Table.objects.select_related().all()
type(qs)
class 'django.contrib.gis.db.models.query.GeoQuerySet'
qs.values()
[{'geom': <MultiPoint object at 0x7f5ce50fc400>, 'id': 2,
'network_id': None, 'user_id': 1, 'name': 'DJANGO', 'lib_type_id': 1,
...
次に、HTML に入れる GeoJSON 形式にします。
properties = Table._meta.get_all_field_names()
djf = Django.Django(geodjango='geom', properties = properties)
geoj = GeoJSON.GeoJSON()
geoj.encode(djf.decode(qs))
そして、私はエラーが発生します:
TypeError: <User: username> is not JSON serializable
問題のユーザー名は、ForeignKey であり、CharField です。シリアライズ可能にするには何を変更する必要がありますか? ありがとう