Questions tagged [django-rest-framework-gis]

Use this tag for general usage questions about django-rest-framework-gis.

37 questions
10
votes
1 answer

How to use MultiPartParser in Django Rest Framework

I need to upload a file and some JSON associated with it. But I don't understand how to save the different parts, specifically the JSON part i.e. I'm able to save the image but not the JSON. I read that I need to use a MultiPartParser but I can't…
9
votes
4 answers

restframework 'tuple' object has no attribute '_meta'

Django throws the next exception: restframework 'tuple' object has no attribute '_meta' Model class BDetail(models.Model): lat = models.FloatField(blank=True, null=True) lng = models.FloatField(blank=True, null=True) class Meta: #…
6
votes
2 answers

How can I flatten a foreignkey object with django-rest-framework-(gis)

I have searched long and far for a solution that is up to date and specific to my problem but have yet not found a solution or a clear documentation on what I really need to do in order to flatten a relationship to become geojson compliant. This…
4
votes
1 answer

GIS - Can i have multple geo_fields (point, polygon, line) in 1 model and then serialize with DRF?

If I have 1 model with 3 different geo_fields in (point, poly and line), can I serialize all of these with django-rest-framework-gis? My model: class Job(BaseModel): name = models.CharField(max_length=64) desc =…
4
votes
0 answers

DRF ListView with GeometryFilter

I am writing an API that should return all objects whose geometry intersects the given geometry (EWKT or WKT format, to be defined). I am trying to use django-rest-framework-gis.filters but not working so far. What I have tried : models.py: class…
4
votes
2 answers

Reduce precision of multi polygon field with django rest framwork gis

I'm using django rest gis to load up leaflet maps, and at the top level of my app I'm looking at a map of the world. The basemap is from Mapbox. I make a call to my rest-api and return an outline of all of the individual countries that are included…
4
votes
1 answer

Conditionally choose serializer

I have three Django models. class Asset(models.Model): name = models.CharField(max_length=255) class Place(Asset): location = PointField() class Zone(Asset): location = PolygonField() I want to use the same endpoint for Place and Zone. Is…
Helgi
  • 338
  • 2
  • 5
  • 11
3
votes
3 answers

Including additional data in Django DRF serializer response that doesn't need to be repeated every entry?

Our Django project sends GeoFeatureModelSerializer responses and we want to include an additional value in this response for JS to access. We figured out how to do this in serializers.py: from rest_framework_gis import serializers as…
3
votes
2 answers

How to deserialize a GeoServer WFS GeoJSON?

TL:DR I want to deserialize a GeoServer WFS FeatureCollection in GeoJSON format into a GeometryField/GeometryCollection. Let's start with the model: class Layer(models.Model): name = models.CharField(max_length=50) layer =…
3
votes
1 answer

Django - Get centroid of polygon in geoJSON format

I'm building a REST API to manage geo-related data. My front-end developer wants to retrieve the centroid of polygons, depending on zoom level, in geoJSON format. My polygon model is as follows: ... from django.contrib.gis.db import models as…
3
votes
1 answer

PUT, GET ,POST ,DELETE methods using djangorest framework

I'm using django rest framework , I use the post and get methods and it works, but I didn't understand how to use PUT and DELETE, do I use it in the html forms like : method='PUT' ? but i read that the browsers assimilated it to a GET method , do I…
3
votes
2 answers

django-rest-framework-gis related field

I have a geographical model structure where multiple events can have the same location: class Event(models.Model): name = models.CharField(max_length=128, blank=True, null=True) location = models.ForeignKey('MarketLocation', null=True,…
3
votes
1 answer

How to get GeoJSON response in Django REST framework gis

I am trying to get GeoJSON response using django rest framework but facing issue argument of type 'NoneType' is not iterable This is my code class NewPark(models.Model): name = models.CharField(max_length=256) geometry =…
3
votes
2 answers

How to transform geometry in django rest framework gis

I am newbie to Django and developing a REST API using Django Rest Framework (DRF) and GIS. Previously, I was using an SQL query for transforming a geometry: select id, name, round(value::numeric, 2) as value, st_transform(geometry,…
2
votes
0 answers

GDALException OGR failure

I am working with Django DRF and GeoDjango for a simple model which is as follows. class Company(models.Model): name = models.CharField(max_length=200, default='Company', null=True) def __unicode__(self): return self.name class…
1
2 3