15 lines
451 B
Python
15 lines
451 B
Python
import json
|
|
|
|
from apps.main.models.model_building import Building
|
|
from django.core.serializers import serialize
|
|
from django.http import HttpRequest, JsonResponse
|
|
from django.views import View
|
|
|
|
|
|
class PolygonsApiView(View):
|
|
def get(self, request: HttpRequest) -> JsonResponse:
|
|
data = serialize(
|
|
"geojson", Building.objects.all(), geometry_field="polygon", fields=["name"]
|
|
)
|
|
return JsonResponse(json.loads(data))
|