TransWikia.com

DoesNotExist: WorldBorder matching query does not exist

Geographic Information Systems Asked by Richard Ilupeju on December 22, 2020

I recently started the geodjango tutorial from the django documentation, but I’m currently stuck because I keep getting a DoesNotExist: WorldBorder matching query does not exist error when I run WorldBorder.objects.get(mpoly__intersects=pnt) in the shell.

This is my models.py file

from django.contrib.gis.db import models
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, null=True)
    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 don’t know if the error is from the world borders zip file I downloaded (but that was the file from the official django tutorial) and I’ve been getting data from importing DataSource but this time around it is not working. I’ve been stuck on this for a while now.

NB: There was a part in the tutorial where I was supposed to run this
from pathlib import Path import world world_shp = Path(world.__file__).resolve().parent / 'data' / 'TM_WORLD_BORDERS-0.3.shp'in django shell but I was getting a WindowsPath not subscriptable error. And since I did not know what to do I just skipped it, so is it possible that that might be the reason for this?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP