I'm using vectorformats
to display GeoDjango data on my map, following this resource. I have this in my views.py
file :
def geojsonFeed(request):
querySet = WorldBorder.objects.filter()
djf = Django.Django(geodjango="mpoly", properties=['name', 'iso3'])
geoj = GeoJSON.GeoJSON()
s = geoj.encode(djf.decode(querySet))
return HttpResponse(s)
But the response looks like this
["type", "features", "crs"]
Can anyone help me identify what's wrong with my code?
Update : Added WorldBorder Model
class WorldBorder(models.Model):
# Regular Django fields corresponding to the attributes in the
# world borders shapefile.
name = models.CharField(max_length=50)
area = models.IntegerField()
pop2005 = models.IntegerField('Population 2005')
fips = models.CharField('FIPS Code', max_length=2)
iso2 = models.CharField('2 Digit ISO', max_length=2)
iso3 = models.CharField('3 Digit ISO', max_length=3)
un = models.IntegerField('United Nations Code')
region = models.IntegerField('Region Code')
subregion = models.IntegerField('Sub-Region Code')
lon = models.FloatField()
lat = models.FloatField()
# GeoDjango-specific: a geometry field (MultiPolygonField)
mpoly = models.MultiPolygonField()
# Returns the string representation of the model.
def __str__(self):
return self.name
I'm using Django 2.1.7
Update 2 :
>>> print(querySet)
<QuerySet [<WorldBorder: Antigua and Barbuda>, <WorldBorder: Algeria>, <WorldBorder: Azerbaijan>, <WorldBorder: Albania>, <WorldBorder: Anguilla>, <WorldBorder: Armenia>, <WorldBorder: Angola>, <WorldBorder: American Samoa>, <WorldBorder: Argentina>, <WorldBorder: Australia>, <WorldBorder: Andorra>, <WorldBorder: Gibraltar>, <WorldBorder: Bahrain>, <WorldBorder: Barbados>, <WorldBorder: Bermuda>, <WorldBorder: Bahamas>, <WorldBorder: Bangladesh>, <WorldBorder: Brunei Darussalam>, <WorldBorder: Canada>, <WorldBorder: Cambodia>, '...(remaining elements truncated)...']>