Когда я пытаюсь вызвать API для URL одной из моих моделей, я сталкиваюсь со следующим:
Cannot set Allotment SpatialProxy (POLYGON) with value of type: <class 'django.contrib.gis.geos.polygon.Polygon'>
Я проверяю определение моей модели и тип данных в PGadmin.
полный журнал
Traceback:
File "/home/user/MyProjects/forest-venv/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
35. response = get_response(request)
File "/home/user/MyProjects/forest-venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
128. response = self.process_exception_by_middleware(e, request)
File "/home/user/MyProjects/forest-venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
126. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/user/MyProjects/forest-venv/lib/python3.5/site-packages/django/views/decorators/csrf.py" in wrapped_view
54. return view_func(*args, **kwargs)
File "/home/user/MyProjects/forest-venv/lib/python3.5/site-packages/rest_framework/viewsets.py" in view
103. return self.dispatch(request, *args, **kwargs)
File "/home/user/MyProjects/forest-venv/lib/python3.5/site-packages/rest_framework/views.py" in dispatch
483. response = self.handle_exception(exc)
File "/home/user/MyProjects/forest-venv/lib/python3.5/site-packages/rest_framework/views.py" in handle_exception
443. self.raise_uncaught_exception(exc)
File "/home/user/MyProjects/forest-venv/lib/python3.5/site-packages/rest_framework/views.py" in dispatch
480. response = handler(request, *args, **kwargs)
File "/home/user/MyProjects/forest-venv/lib/python3.5/site-packages/rest_framework/mixins.py" in list
42. page = self.paginate_queryset(queryset)
File "/home/user/MyProjects/forest-venv/lib/python3.5/site-packages/rest_framework/generics.py" in paginate_queryset
173. return self.paginator.paginate_queryset(queryset, self.request, view=self)
File "/home/user/MyProjects/forest-venv/lib/python3.5/site-packages/rest_framework/pagination.py" in paginate_queryset
337. return list(queryset[self.offset:self.offset + self.limit])
File "/home/user/MyProjects/forest-venv/lib/python3.5/site-packages/django/db/models/query.py" in __iter__
272. self._fetch_all()
File "/home/user/MyProjects/forest-venv/lib/python3.5/site-packages/django/db/models/query.py" in _fetch_all
1179. self._result_cache = list(self._iterable_class(self))
File "/home/user/MyProjects/forest-venv/lib/python3.5/site-packages/django/db/models/query.py" in __iter__
63. obj = model_cls.from_db(db, init_list, row[model_fields_start:model_fields_end])
File "/home/user/MyProjects/forest-venv/lib/python3.5/site-packages/django/db/models/base.py" in from_db
507. new = cls(*values)
File "/home/user/MyProjects/forest-venv/lib/python3.5/site-packages/django/db/models/base.py" in __init__
424. _setattr(self, field.attname, val)
File "/home/user/MyProjects/forest-venv/lib/python3.5/site-packages/django/contrib/gis/db/models/proxy.py" in __set__
75. instance.__class__.__name__, gtype, type(value)))
Exception Type: TypeError at /api/cutarea-allotment/
Exception Value: Cannot set Allotment SpatialProxy (POLYGON) with value of type: <class 'django.contrib.gis.geos.polygon.Polygon'>
Это определение модели:
from renter.models import *
from classification_list.models import*
from django.contrib.gis.db import models
from django.contrib.gis.geos import Polygon
...
class All(models.Model):
geom = models.PolygonField(geography=True, null=True, blank=True, verbose_name='geom')
num_kvr = models.ForeignKey(QartalKeys, models.DO_NOTHING, blank=True, null=True)
allot_num = models.SmallIntegerField(blank=True, null=True)
Что не так?Я не нашел соответствующей проблемы или полезного предложения для этой проблемы.Спасибо.