Use this tag for general usage questions about django-rest-framework-gis.
Questions tagged [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…

Jenia Ivanov
- 2,485
- 3
- 41
- 69
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:
#…

cristian camilo cedeño gallego
- 3,502
- 4
- 20
- 31
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…

Niclas
- 510
- 6
- 19
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 =…

trouselife
- 971
- 14
- 36
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…

stellasia
- 5,372
- 4
- 23
- 43
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…

geoAndrew
- 347
- 1
- 12
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…

for_all_intensive_purposes
- 906
- 10
- 16
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 =…

John Moutafis
- 22,254
- 11
- 68
- 112
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…

GwydionFR
- 787
- 1
- 10
- 25
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…

sarra
- 23
- 5
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,…

Simon Greenwood
- 161
- 1
- 7
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 =…

Shoaib Ijaz
- 5,347
- 12
- 56
- 84
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,…

Shoaib Ijaz
- 5,347
- 12
- 56
- 84
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…

Syed Raza Abbas SRA
- 91
- 1
- 8