I am trying to get GeoJSON response using django rest framework but facing issue
argument of type 'NoneType' is not iterableThis is my code
class NewPark(models.Model):
name = models.CharField(max_length=256)
geometry = models.GeometryField(srid=3857, null=True, blank=True)
objects = models.GeoManager()
class Meta:
db_table = u'new_park'
def __unicode__(self):
return '%s' % self.name
class NewParkSerializer(GeoFeatureModelSerializer):
class Meta:
model = NewPark
geo_field = "geometry"
fields = ('id', 'name', 'geometry')
class NewParkViewSet(viewsets.ModelViewSet):
def get_queryset(self):
queryset = NewPark.objects.all()
return querysetWhen i change serialize type to 'erializers.GeoModelSerializer' then it is working, but i want GEOJSON response
I have searched about GeoFeatureModelSerializer but cannot find any example geo_field = "geometry". All example are about geo_field = "point"
Please help me to figure out this issue?
class NewParkSerializer(GeoFeatureModelSerializer):
class Meta:
model = NewPark
geo_field = "geometry"
id_field = False
fields = ('id', 'name')
--
You received this message because you are subscribed to the Google Groups "Django REST Framework GIS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framew...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework-gis+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framew...@googlegroups.com.
geometry = models.GeometryField(srid=3857, null=True, blank=True)
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework-gis+unsubsc...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framew...@googlegroups.com.
Environment: Request Method: GET Request URL: http://127.0.0.1:8001/PoiLorryparkViewSet/ Django Version: 1.6 Python Version: 2.7.1 Installed Applications: ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'django.contrib.gis', 'data_api', 'rest_framework') Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware') Traceback: File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response 139. response = response.render() File "C:\Python27\lib\site-packages\django\template\response.py" in render 105. self.content = self.rendered_content File "C:\Python27\lib\site-packages\rest_framework\response.py" in rendered_content 59. ret = renderer.render(self.data, media_type, context) File "C:\Python27\lib\site-packages\rest_framework\renderers.py" in render 592. context = self.get_context(data, accepted_media_type, renderer_context) File "C:\Python27\lib\site-packages\rest_framework\renderers.py" in get_context 569. 'post_form': self.get_rendered_html_form(view, 'POST', request), File "C:\Python27\lib\site-packages\rest_framework\renderers.py" in get_rendered_html_form 448. serializer.is_valid() File "C:\Python27\lib\site-packages\rest_framework\serializers.py" in is_valid 551. return not self.errors File "C:\Python27\lib\site-packages\rest_framework\serializers.py" in errors 543. ret = self.from_native(data, files) File "C:\Python27\lib\site-packages\rest_framework_gis\serializers.py" in from_native 115. if 'features' in data: Exception Type: TypeError at /PoiLorryparkViewSet/ Exception Value: argument of type 'NoneType' is not iterable
geometry = models.GeometryField()To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework-gis+unsubsc...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framew...@googlegroups.com.
class AccountViewSet(viewsets.ModelViewSet):
"""
A simple ViewSet for viewing and editing accounts.
"""
queryset = Account.objects.all()
serializer_class = AccountSerializer
permission_classes = [IsAccountAdminOrReadOnly]
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework-gis+unsub...@googlegroups.com.
if 'features' in data: Exception Type: TypeError at /PoiLorryparkViewSet/
Exception Value: argument of type 'NoneType' is not iterableTo unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framew...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework-gis+unsubsc...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framew...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framew...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework-gis+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django REST Framework GIS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework-gis+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django REST Framework GIS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework-gis+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framew...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framew...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framew...@googlegroups.com.
from django.contrib.gis.db import modelsfrom django.contrib.auth.models import Userclass PoiLorrypark(models.Model):name = models.CharField(max_length=256)postcode = models.CharField(max_length=8, blank=True)phone = models.CharField(max_length=256, blank=True)email = models.CharField(max_length=256, blank=True)web = models.TextField(blank=True)geometry = models.GeometryField()
objects = models.GeoManager()class Meta:
db_table = u'lorrypark'
I am using django built in webserver and IDE is JetBrains PyCharm
I don't think because i am using some rest_framework_gis function that working perfectly, but now i added rest_framework_gis in installed aps , same issue
/api/newpark?format=json
Now My question is, how can i make it browsable api. is there any solution exist?i am having same problem and are using ViewSets,
is this any type of bug or anything missing on my side?