当我试图运行这个脚本时,我得到了这个错误" django.core.exceptions.FieldDoesNotExist:No_Address没有名为' False' "

时间:2018-05-29 10:08:48

标签: python django django-models geodjango

我的 models.py

class No_Address(models.Model):
    id = models.CharField(max_length=12,primary_key = True)
    address = models.CharField(max_length=30)
    city = models.CharField(max_length=30)
    zip = models.CharField(max_length=10)
    state = models.CharField(max_length=2)
    primpgon = models.BigIntegerField()
    numpgons = models.BigIntegerField()
    x = models.FloatField()
    y = models.FloatField()
    censusbloc = models.CharField(max_length=15)
    objectid = models.BigIntegerField()
    geom = models.MultiPolygonField(srid=4326)

引发错误的代码:

import os
from django.contrib.gis.utils import LayerMapping
from .models import No_Address

no_address_mapping = {
    'id' : 'ID',
    'address' : 'Address',
    'city' : 'City',
    'zip' : 'ZIP',
    'state' : 'State',
    'primpgon' : 'PrimPgon',
    'numpgons' : 'NumPgons',
    'x' : 'X',
    'y' : 'Y',
    'censusbloc' : 'CensusBloc',
    'objectid' : 'ObjectID',
}
no_address_shp = os.path.abspath(
    os.path.join(
        os.path.dirname(__file__),
        'building/WestDV_CA_BF_NoAddress_region.shp'))

def run(verbose=True):
    lm = LayerMapping(
        No_Address, no_address_shp, no_address_mapping,
        transform=False, encoding='iso-8859-1')
    lm.save(strict=True, verbose=verbose)

当我尝试将shapefile导入数据库时​​,我收到此错误。

当我尝试运行此脚本时,我收到This Field Does not exist错误。

我很困惑,为什么我收到这个错误。

0 个答案:

没有答案