GeoDjango:“QuerySet”对象没有属性“transform”

2024-09-30 10:41:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下三个模型,我希望在这三个模型中实现以下目标:

  • 获取特定所有者(所有者)拥有的所有geom(butuanmap)
  • 显示LandProperty模型中的几何图形(ButuanMaps)信息

在py模型在

class Owner(models.Model):
    GENDER_CHOICES = (
        ('Male', 'Male'),
        ('Female', 'Female'),
    )
    MARITAL_STATUS_CHOICES = (
        ('Single', 'Single'),
        ('Married', 'Married'),
        ('Widowed', 'Widowed'),
        ('Divorced', 'Divorced'),
    )
    user= models.OneToOneField(User)
    spersonid = models.ForeignKey(Information)
    ctin = models.CharField("TIN",max_length=50)
    csss = models.CharField("SSS", max_length=50)
    crescertificate = models.CharField("Res. Certificate", max_length=50)
    cgender = models.CharField("Gender", max_length=10, choices=GENDER_CHOICES, null=True, blank=True)
    cmaritalstatus = models.CharField("Marital Status", max_length=50, choices=MARITAL_STATUS_CHOICES, null=True, blank=True)

    User.profile = property(lambda u: Owner.objects.get_or_create(user=u)[0])

    def __unicode__(self):
        return self.spersonid.cfirstname


class ButuanMaps(gismodel.Model):
    class Meta:
        verbose_name = u'Butuan Map'
        verbose_name_plural = u'Butuan Maps'

    clandpin = gismodel.CharField("Land PIN", max_length=50, null=True, blank=True)
    ssectionid = gismodel.ForeignKey(Section)
    #ssectionid_id = gismodel.IntegerField()
    geom = gismodel.MultiPolygonField("Geom ID", srid=32651, null=True, blank=True)
    objects = gismodel.GeoManager()

    def __unicode__(self):
        return self.clandpin


class LandProperty(models.Model):
    DEFAULT_OWNER_ID = 5
    class Meta:
        verbose_name = u'Land Property'
        verbose_name_plural = u'Land Properties'
    ctaxdec = models.CharField("Tax Declaration", max_length=50, null=True, blank=True)
    sgeomid = models.ForeignKey(ButuanMaps)
    sownerid = models.ForeignKey(Owner, default=DEFAULT_OWNER_ID)
    clotno = models.CharField("Lot Nos.", max_length=50, null=True, blank=True)
    iblockno = models.IntegerField("Block Nos.", null=True, blank=True)
    csurveyno = models.CharField("Survey Nos.", max_length=50, null=True, blank=True)
    cstreet = models.CharField("Street", max_length=50, null=True, blank=True)
    nfrontage = models.CharField("Frontage", max_length=50, null=True, blank=True)
    nkmstoweather = models.FloatField("Kms. to Weather", null=True, blank=True)
    nkmstomarket = models.FloatField("Kms. to Market", null=True, blank=True)
    cnorth = models.CharField("North", max_length=50, null=True, blank=True)
    csouth = models.CharField("South", max_length=50, null=True, blank=True)
    ceast = models.CharField("East", max_length=50, null=True, blank=True)
    cwest = models.CharField("West", max_length=50, null=True, blank=True)

    def __unicode__(self):
        return self.sgeomid.clandpin

在视图.py在

^{pr2}$

Tags: name模型selftrueverbosemodelsnulllength

热门问题